Php cannot use object stdClass as array
Derp.
Getting 'Fatal error: Cannot use object of type stdClass as array'

I dunno what I'm doing wrong here:



	foreach ($json->result->items[$key]->attributes->attribute as $attrib => $val) 
	{
		if($json->result->items[$key]->attributes->attribute[$attrib]->name == 'cannot_trade')
		{
			$notrade=1;
			echo 'Item ' . $key . ' is not tradeable' . $br;
		}
	}

And here's the data:

                            [attributes] => stdClass Object
                                (
                                    [attribute] => Array
                                        (
                                            [0] => stdClass Object
                                                (
                                                    [name] => custom employee number
                                                    [class] => set_employee_number
                                                    [value] => 0
                                                )

                                            [1] => stdClass Object
                                                (
                                                    [name] => cannot trade
                                                    [class] => cannot_trade
                                                    [value] => 1
                                                )

                                        )

                                )
Essentially, I'm trying to test to see if the 'attribute' array has the cannot_trade thingy.
Sometimes, the parent object doesn't have an 'attributes' object
Php cannot use object stdClass as array
===

Derp.
Getting 'Fatal error: Cannot use object of type stdClass as array'

I dunno what I'm doing wrong here:



	foreach ($json->result->items[$key]->attributes->attribute as $attrib => $val) 
	{
		if($json->result->items[$key]->attributes->attribute[$attrib]->name == 'cannot_trade')
		{
			$notrade=1;
			echo 'Item ' . $key . ' is not tradeable' . $br;
		}
	}

And here's the data:

                            [attributes] => stdClass Object
                                (
                                    [attribute] => Array
                                        (
                                            [0] => stdClass Object
                                                (
                                                    [name] => custom employee number
                                                    [class] => set_employee_number
                                                    [value] => 0
                                                )

                                            [1] => stdClass Object
                                                (
                                                    [name] => cannot trade
                                                    [class] => cannot_trade
                                                    [value] => 1
                                                )

                                        )

                                )
Essentially, I'm trying to test to see if the 'attribute' array has the cannot_trade thingy.
Sometimes, the parent object doesn't have an 'attributes' object