0

So I am trying to target an object like this:

$subject = $obj->$field->{'$postID-subject'};

I always get a returned value of 0. Any thoughts?

Nick
  • 790
  • 11
  • 29

1 Answers1

2

Try that:

  $field2 ="{$postID}-subject";
  $subject = $obj->$field->$field2;

Proof of concept:

 $a = new stdClass(); 
 $a->{"A-A"} = 'B'; 
 print $a->{"A-A"};

:)

RiggsFolly
  • 89,708
  • 20
  • 100
  • 143
JustOnUnderMillions
  • 3,708
  • 8
  • 11
  • `Try that` answers get dropped in the list even below an answer with -2 A bit of explanation with lift you above at least one of those millions – RiggsFolly Jul 12 '16 at 15:40