PHP - How to navigate this array dynamically
Have an issue with the following array... I can't navigate it using $arrayname[0]... it has to be $arrayname[111]... Is there a way to make this work the first way? That first number is dynamic.
array(1) { [111]=> object(stdClass)#202 (24) {
["ID"]=> int(111)
["post_author"]=> string(1)"2"
["post_date"]=> string(19) "2011-03-18 14:36:08"
["post_date_gmt"]=> string(19) "2011-03-18 18:36:08"
["post_content"]=> string(0) ""
["post_title"]=> string(23) "Kyle Hotchkiss' Mugshot"
["post_excerpt"]=> string(0) ""
["post_status"]=> string(7) "inherit"
["comment_status"]=> 开发者_JAVA技巧string(4) "open"
["ping_status"]=> string(4) "open" ["post_password"]=> string(0) ""
["post_name"]=> string(18) "mugshot_khotchkiss" ["to_ping"]=> string(0) "" ["pinged"]=> string(0) ""
["post_modified"]=> string(19) "2011-03-18 14:36:08"
["post_modified_gmt"]=> string(19) "2011-03-18 18:36:08" ["post_content_filtered"]=> string(0) ""
["post_parent"]=> int(106)
["guid"]=> string(66) "http://hotchkissmade.com/wp-content/uploads/mugshot_khotchkiss.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"
} }
foreach ($arrayname as $foo)
{
// profit
}
Or you can just:
$arrayname = array_values($arrayname); // resort to 0 ... n-1
Whichever you prefer.
http://de2.php.net/manual/de/function.array-shift.php gives you the first element in the array. It seems that your Tool stores the array-entry at the id (111). Are there any other elements in the array at anytime?
精彩评论