Sekoul Sekoul - 2 months ago 6x
PHP Question

PHP - refer to stdclass object within array


I'm trying to refer to value below:

Array (
[0] => stdClass Object (
[label] => Nancy Adler
[attributes] => Array (
[class] => sf-level-0 sf-item-14
[value] => adler-nancy
[depth] => 0
[count] => 3
[1] =>... etc.


Assuming the array is called $array, what would be the right format for this? I've tried
, but it does not work.


Tough to say with your formatting. but:


The first element in the array is of type stdClass Object, so to access its members, you use the object accessor -> rather than the array syntax.

PS: Kudos to Marc for making things legible with his edit.