另一个数组里面stdClass的对象数组 [英] stdClass object array inside of another array
本文介绍了另一个数组里面stdClass的对象数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从下面的$ array1中的信息。
我做得到没有问题的场所的名称和位置地址:
$数组2 =阵列();
$ ARRAY3 =阵列();
的foreach($数组1为$项目){ $数组2 [] = $本期特价货品> venue->名;
$ ARRAY3 [] = $本期特价货品> venue->位置 - >地址;
}
但现在我需要得到的照片网址,我不知道该怎么做。
太感谢了!
$ ARRAY1:
阵列
(
[0] => stdClass的对象
(
[地点] => stdClass的对象 ( [名] =>一个名字
[位置] => stdClass的对象
(
[地址] =>主要街道 )
) [组图] = GT; stdClass的对象
(
[计] => 1
[项目] =>排列
(
[0] => stdClass的对象
( [URL] => HTTP://folder/photo1.jpg 。
。
)))
。
。
解决方案
$数组1 [0] - > photos->项目[0] - >网址
记住 - 以您访问数组[索引]
括号,用对象 - >
箭头
I'm trying to get information from the $array1 below.
I'm getting with no problems venue's name and location address by doing:
$array2 = array();
$array3 = array();
foreach($array1 as $item){
$array2[] = $item->venue->name;
$array3[] = $item->venue->location->address;
}
But now I need to get the photos url and I don't know how to do it.
Thanks a million!
$array1:
Array
(
[0] => stdClass Object
(
[venue] => stdClass Object
(
[name] => a name
[location] => stdClass Object
(
[address] => main street
)
)
[photos] => stdClass Object
(
[count] => 1
[items] => Array
(
[0] => stdClass Object
(
[url] => http://folder/photo1.jpg
.
.
)))
.
.
解决方案
$array1[0]->photos->items[0]->url
Remember - you access arrays with [index]
parenthesis, objects with ->
arrows.
这篇关于另一个数组里面stdClass的对象数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文