我有两个数组...多数组**第一个调用位置并进入它(城市名称)我想获取元素名称但不是第一个或最后一个如何做到这一点
location":Array (
[0] => stdClass Object ([code] => BKK [name] => Bangkok )
[1] => stdClass Object ( [code] => SIN [name] => Singapore Changi )
[2] => stdClass Object ( [code] => KUL [name] => Kuala Lumpur ) )
我的代码不起作用
<?php
foreach ($obj->location as $lo):
if (!reset(reset($lo)) and !end(end($lo))) {
echo $lo->name . ',';
}
endforeach;
?>