Printing out Sections of an array not working like I thought

I have an array which is printing out like this:

Array ( [0] => stdClass Object ( [term_id] => 4 [name] => Web Layouts [slug] => web-layouts [term_group] => 0 [term_taxonomy_id] => 4 [taxonomy] => category [description] => [parent] => 1 [count] => 2 [object_id] => 6 [cat_ID] => 4 [category_count] => 2 [category_description] => [cat_name] => Web Layouts [category_nicename] => web-layouts [category_parent] => 1 ) )

I’m trying to print out just the name of the item in the array this is what I tried:

print $postCategory[0][‘name’];

but it gives me this error message:

Fatal error: Cannot use object of type stdClass as array in

I’m not familiar with the stdClass, any idea what to do?

You have an array of objects, so you can’t access the object properties with array syntax.
use $postCategory[0]->name;

Ahh, now I see thanks for the pointer.

BTW out of curiosity why would you use one type over the other?

If you just have, say table rows, then using an array or an object would be mostly personal preference, e.g. db libraries will usually give you an option to return either.

Objects and OOP are a lot more than this though, wiki has a page with more info. Or the [URL=“”]php manual.

Awesome, thanks for your help.