从mysql数组获取id

I'm running a query that returns the following array ($array) when I executie print_r on it:

Array ( [0] => Photo Object ( [id] => 105 [name] => .png [extention] => _klein [tags] => 4 [target_file] => [imagelib_id] => 1))

How do I access the id value. It should be just $array['id']; right? I'm getting no value at all out of this

Solution! $array[0]->id;... Because it's an object you have to access it like an object... This returns the id of object 0. Thanks for your help :)

Based on your example, you could access the 'id' value as follows:

$array[0]['id'];

It's multidimensional array. First nested array is 0. You must refer to it accordingly!

your array name is $array then

 echo $array[0]['id'];

gives you id value

Because your first item is a Photo object, I would do this (considering id is public):

// $array = Array ( [0] => Photo Object ( [id] => 105 [name] => .png [extention] => _klein [tags] => 4 [target_file] => [imagelib_id] => 1))
var_dump(reset($array)->id);

reset() resets the internal pointer, so always pics the first element, this is nice when your array starts at another index, say 4.