我有以下数组,如何编写循环列出名称和ID?
Array
(
[data] => Array
(
[0] => Array
(
[name] => Test name
[id] => 110
)
[1] => Array
(
[name] => Test name 2
[id] => 111
)
[2] => Array
(
[name] => Test name 3
[id] => 124
)
[3] => Array
(
[name] => Test name 4
[id] => 105
)
[4] => Array
(
[name] => Test name 5
[id] => 56
)
)
)
感谢您的帮助:)
答案 0 :(得分:4)
像这样:
foreach ($array['data'] as $key => $value) {
echo $value['name'];
echo $value['id'];
}
答案 1 :(得分:2)
简单的一个:
foreach($array['data'] as $item){
echo $item['id'].'. '.$item['name'];
}