首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >解析PHP数组

解析PHP数组
EN

Stack Overflow用户
提问于 2011-12-14 11:47:40
回答 1查看 460关注 0票数 0

我已经成功地达到了这样的阶段,我有一个看起来像这样的数组。使用(zend_json解码json响应)

代码语言:javascript
运行
复制
Array
(
[response] => Array
    (
        [status] => ok
        [userTier] => free
        [total] => 10
        [startIndex] => 1
        [pageSize] => 10
        [currentPage] => 1
        [pages] => 1
        [results] => Array
            (
                [0] => Array
                    (
                        [id] => lifeandstyle/series/cycling
                        [type] => series
                        [webTitle] => Cycling
                        [webUrl] => http://www.guardian.co.uk/lifeandstyle/series/cycling
                        [apiUrl] => http://content.guardianapis.com/lifeandstyle/series/cycling
                        [sectionId] => lifeandstyle
                        [sectionName] => Life and style
                    )

                [1] => Array
                    (
                        [id] => sport/cycling
                        [type] => keyword
                        [webTitle] => Cycling
                        [webUrl] => http://www.guardian.co.uk/sport/cycling
                        [apiUrl] => http://content.guardianapis.com/sport/cycling
                        [sectionId] => sport
                        [sectionName] => Sport
                    )

我如何开始只解析webTitle和webUrl元素

谢谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-12-14 11:50:16

您不能只解析这些部分,但可以遍历结果并访问它们。

代码语言:javascript
运行
复制
foreach ($val['response']['results'] as $result) {
  $title = $result['webTitle']; 
  $url = $result['webUrl'];

  // ...
}
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8499271

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档