php大神解答下

查看:78
本文介绍了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;
}

这篇关于php大神解答下的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆