Здраствуйте камрады. Есть следующая задача. Имею многомерный массив, такого вида: Код (Text): array(3) { [199]=> object(WP_Post)#2029 (26) { ["ID"]=> int(199) ["post_author"]=> string(1) "1" ["post_date"]=> string(19) "2013-10-12 03:05:59" ["post_date_gmt"]=> string(19) "2013-10-11 23:05:59" ["post_content"]=> string(0) "" ["post_title"]=> string(32) "d383d3fffd71164f8a7f5049048a33c4" ["post_excerpt"]=> string(0) "" ["post_status"]=> string(7) "inherit" ["comment_status"]=> string(4) "open" ["ping_status"]=> string(4) "open" ["post_password"]=> string(0) "" ["post_name"]=> string(32) "d383d3fffd71164f8a7f5049048a33c4" ["to_ping"]=> string(0) "" ["pinged"]=> string(0) "" ["post_modified"]=> string(19) "2013-10-12 03:05:59" ["post_modified_gmt"]=> string(19) "2013-10-11 23:05:59" ["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(175) ["guid"]=> string(79) "http://site/wp-content/uploads/2013/10/d383d3fffd71164f8a7f5049048a33c4.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" ["format_content"]=> NULL ["robotsmeta"]=> NULL } [200]=> object(WP_Post)#2028 (26) { ["ID"]=> int(200) ["post_author"]=> string(1) "1" ["post_date"]=> string(19) "2013-10-12 03:06:01" ["post_date_gmt"]=> string(19) "2013-10-11 23:06:01" ["post_content"]=> string(0) "" ["post_title"]=> string(51) "Downtown Pano, from Old Town, Burj Khalifa Nov 2012" ["post_excerpt"]=> string(0) "" ["post_status"]=> string(7) "inherit" ["comment_status"]=> string(4) "open" ["ping_status"]=> string(4) "open" ["post_password"]=> string(0) "" ["post_name"]=> string(49) "downtown-pano-from-old-town-burj-khalifa-nov-2012" ["to_ping"]=> string(0) "" ["pinged"]=> string(0) "" ["post_modified"]=> string(19) "2013-10-12 03:06:01" ["post_modified_gmt"]=> string(19) "2013-10-11 23:06:01" ["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(175) ["guid"]=> string(96) "http://site/wp-content/uploads/2013/10/Downtown-Pano-from-Old-Town-Burj-Khalifa-Nov-2012.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" ["format_content"]=> NULL ["robotsmeta"]=> NULL } [201]=> object(WP_Post)#2027 (26) { ["ID"]=> int(201) ["post_author"]=> string(1) "1" ["post_date"]=> string(19) "2013-10-12 03:06:03" ["post_date_gmt"]=> string(19) "2013-10-11 23:06:03" ["post_content"]=> string(0) "" ["post_title"]=> string(21) "Dubai-Intl-Motor-Show" ["post_excerpt"]=> string(0) "" ["post_status"]=> string(7) "inherit" ["comment_status"]=> string(4) "open" ["ping_status"]=> string(4) "open" ["post_password"]=> string(0) "" ["post_name"]=> string(23) "dubai-intl-motor-show-2" ["to_ping"]=> string(0) "" ["pinged"]=> string(0) "" ["post_modified"]=> string(19) "2013-10-12 03:06:03" ["post_modified_gmt"]=> string(19) "2013-10-11 23:06:03" ["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(175) ["guid"]=> string(69) "http://site/wp-content/uploads/2013/10/Dubai-Intl-Motor-Show1.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" ["format_content"]=> NULL ["robotsmeta"]=> NULL } } как мне построчно извлечь поля ["guid"], а точнее урлы. Следующий шаблон не работает: Код (Text): $media[199]["guid"]
Во-первых, у вас не многомерный массив (или массив массивов), а массив объектов класса WP_Post (о чём нам говорит слово object ). Соответственно, с каждым элементом надо обращаться именно как с объектом. Во-вторых, учите синтаксис, сложности никакой: Код (PHP): foreach ($media as $m) { echo $m->guid; }