PHP解析数组中的数组 [英] php parse array in array

查看:64
本文介绍了PHP解析数组中的数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个看起来像这样的数组,但是更长了:

I've got an array that looks like this, but much longer:

    Array
   (
   [0] => stdClass Object
   (
        [text] => @TwitterUser. Lorem Ipsum
        [id_str] => 60768083157061632
        [user] => stdClass Object
            (
                [profile_image_url] => http://a0.twimg.com/sticky/default_profile_images/default_profile_3_normal.png
                [screen_name] => MyDude

我只想在此数组中为每个键打印某些值,因此,键的所有值 [text]
[screen_name] 在父键 [0] 通过 [任何内容] 。我觉得我应该做类似 $ foreach 的语句,但是不能弄清楚如何告诉我的机器向下看每个数字父键中的子数组。

I want to print only certain values per key in this array. So, all values for the keys [text] and [screen_name] in parent keys [0] through [whatever]. I feel like I should do something like a $foreach statement, but can't quite figure out how to tell my machine to look down through the child arrays in each of the numerical parent keys.

任何帮助将不胜感激!

推荐答案

foreach($tweets as $tweet) {
    echo $tweet->text;
    echo $tweet->user->screen_name;
}

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

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