0

CONTEXT

I'm trying to refer to value below:

Array (
    [0] => stdClass Object (
        [label] => John Smith
        [attributes] => Array (
            [class] => sf-level-0 sf-item-14
        )
        [value] => smith-john
        [depth] => 0
        [count] => 3
    )
    [1] =>... etc.

QUESTION

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

Sekoul
  • 1,361
  • 2
  • 14
  • 30

1 Answers1

3

Tough to say with your formatting. but:

$array[0]->value

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.

BeetleJuice
  • 39,516
  • 19
  • 105
  • 165