使用PHP代码从多维数组获取数据 [英] get data from multi-dimensional array using PHP code

查看:60
本文介绍了使用PHP代码从多维数组获取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从多维数组中获取此数据[label] => For Rent.这是我的数组

I'm trying to get this data [label] => For Rent from a multi-dimensional array. Here is my array

Array ( [listing_id] => 0 
        [fields] => 
                   Array ( [1] => Property House 7 [2] => 30 [4] => sdfasd
                           [11] => Bungalow [10] => Philippines [12] => 1800100
                           [13] => 1 [14] => 1 [15] => Yes [16] => Yes [17] => Yes
                           [18] => Yes [26] => Yes [25] => Yes [24] => Yes
                           [23] => Yes [22] => Yes [21] => Yes [20] => Yes [19] => Yes) 
        [fees] => Array ( 
            [30] => stdClass Object ( [id] => 2 [label] => For Rent [amount] => 0.00
                                      [days] => 7 [images] => 0
                                      [categories] => 
                                        Array ( [all] => 0 
                                [categories] => Array ( [0] => 30 ) ) [extra_data] => ) ) 

                                [images] => Array ( ) [thumbnail_id] => 0 )

如何使用PHP代码回显值为For Rentlabel

How will I echo the label that has a value of For Rent using PHP code

推荐答案

echo $yourArray['fees'][30]->label

这不仅是一个数组,而是一个包含对象的数组.使用->访问对象属性.

It's not just an array... it's an array with an object in it. Use the -> to access object properties.

这篇关于使用PHP代码从多维数组获取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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