How to deduce im value from this object?

 object(stdClass)#43 (3) { ["num_rows"]=> int(1) ["row"]=> array(1) { ["im"]=> string(58) "Images/Goods/medium/592778.jpg" } ["rows"]=> array(1) { [0]=> array(1) { ["im"]=> string(58) "Images/Goods/medium/592778.jpg" } } } 
  • $obj->row['im'] not? - Dmitriy Simushev
  • Access to the elements of an object occurs through the operator ->, and everything that is in these elements is a regular array, accessible through [] - ilyaplot

2 answers 2

 $var->row['im']; 

Instead of var name of the variable to dump.

     $testArray = (array) $testObject; var_dump($testArray); array(3) { ["num_rows"]=> int(1) ["row"]=> array(1) { ["im"]=> string(30) "Images/Goods/medium/592778.jpg" } ["rows"]=> array(1) { ["im"]=> string(30) "Images/Goods/medium/592778.jpg" } } 

    Just do the conversion with (array) and work like an array

    • 3
      I think you should not "finish" the answers of other authors. You can either leave a comment to the answer, or give your own answer. - Dmitriy Simushev