php大神解答下

 李程VS_328_302 发布于 2022-11-18 17:45
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

2 个回答
  • 递归循环读取

    2022-11-18 19:13 回答
  • 这是一个含有三个WP_Post Object对象元素的数组,获取元素对象后,再获取其属性即可,代码如下:

    foreach($array as $key => $value){
        if($value->post_title)
            echo $value->post_title;
    }
    
    2022-11-18 19:13 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有