首页 > php大神解答下

php大神解答下

Array ( [0] => WP_Post Object ( [ID] => 39 [post_author] => 1 [post_date] => 2016-04-03 21:59:44 [post_date_gmt] => 2016-04-03 13:59:44 [post_content] => 11111 [post_title] => 测试3 [post_excerpt] => [post_status] => publish [comment_status] => open [ping_status] => open [post_password] => [post_name] => %e6%b5%8b%e8%af%953 [to_ping] => [pinged] => [post_modified] => 2016-04-03 21:59:44 [post_modified_gmt] => 2016-04-03 13:59:44 [post_content_filtered] => [post_parent] => 0 [guid] => http://localhost/wordpress/?p=39 [menu_order] => 0 [post_type] => post [post_mime_type] => [comment_count] => 0 [filter] => raw ) [1] => WP_Post Object ( [ID] => 37 [post_author] => 1 [post_date] => 2016-04-03 17:02:16 [post_date_gmt] => 2016-04-03 09:02:16 [post_content] => 测试2 [post_title] => 测试2 [post_excerpt] => [post_status] => publish [comment_status] => open [ping_status] => open [post_password] => [post_name] => %e6%b5%8b%e8%af%952 [to_ping] => [pinged] => [post_modified] => 2016-04-03 17:02:16 [post_modified_gmt] => 2016-04-03 09:02:16 [post_content_filtered] => [post_parent] => 0 [guid] => http://localhost/wordpress/?p=37 [menu_order] => 0 [post_type] => post [post_mime_type] => [comment_count] => 0 [filter] => raw ) [2] => WP_Post Object ( [ID] => 35 [post_author] => 1 [post_date] => 2016-04-03 16:50:04 [post_date_gmt] => 2016-04-03 08:50:04 [post_content] => 测试文章1 [post_title] => 测试文章 [post_excerpt] => [post_status] => publish [comment_status] => open [ping_status] => open [post_password] => [post_name] => %e6%b5%8b%e8%af%95%e6%96%87%e7%ab%a0 [to_ping] => [pinged] => [post_modified] => 2016-04-03 16:50:04 [post_modified_gmt] => 2016-04-03 08:50:04 [post_content_filtered] => [post_parent] => 0 [guid] => http://localhost/wordpress/?p=35 [menu_order] => 0 [post_type] => post [post_mime_type] => [comment_count] => 0 [filter] => raw ) )

这样的数组 怎么用循环取到里面的值 比如取里面的 post_title


递归循环读取


这是一个含有三个WP_Post Object对象元素的数组,获取元素对象后,再获取其属性即可,代码如下:

foreach($array as $key => $value){
    if($value->post_title)
        echo $value->post_title;
}
【热门文章】
【热门文章】