I have an array, named Images and want to get on value from it. This is the data, which my array contains:
array(1) {
[924]=>
object(stdClass)#4240 (24) {
["ID"]=>
int(924)
["post_author"]=>
string(1) "1"
["post_date"]=>
string(19) "2011-07-25 15:20:50"
["post_date_gmt"]=>
string(19) "2011-07-25 15:20:50"
["post_content"]=>
string(0) ""
["post_title"]=>
string(17) "Rezept zum Glück"
["post_excerpt"]=>
string(0) ""
["post_status"]=>
string(7) "inherit"
["comment_status"]=>
string(6) "closed"
["ping_status"]=>
string(4) "open"
["post_password"]=>
string(0) ""
["post_name"]=>
string(19) "rezept-zum-glueck-2"
["to_ping"]=>
string(0) ""
["pinged"]=>
string(0) ""
["post_modified"]=>
string(19) "2011-07-25 15:20:50"
["post_modified_gmt"]=>
string(19) "2011-07-25 15:20:50"
["post_content_filtered"]=>
string(0) ""
["post_parent"]=>
int(922)
["guid"]=>
string(60) "/wp-content/uploads/useruploads/rezept-zum-glueck-bild-1.jpg"
["menu_order"]=>
int(0)
["post_type"]=>
string(10) "attachment"
["post_mime_type"]=>
开发者_开发技巧string(10) "image/jpeg"
["comment_count"]=>
string(1) "0"
["filter"]=>
string(3) "raw"
} }
How do I get the value "guid" from it?
$guid = $your_array[924]->guid
You should read the documentation on arrays and objects to learn more about how this work. Also, what is stdClass.
You have an object as the only element in that array.
I think you want to do $images[924]->guid
depending on if you know the 924 beforehand or not. Otherwise you'll need to do something with a foreach.
This is a hash. How about
$obj = (obj) $my_array["924"];
$guid = obj["guid"];
I am just guessing here, but might work.
精彩评论