我有这个数组
Array
(
[first_information] => Array
(
[0] => 10
[1] => 12
)
[rows] => 1
[0] => Array
(
[data_1] => 1
[data_2] => 2
[data_3] => 3
[data_4] => 4
[data_5] => 5
)
)
我应该如何仅显示[first_information]内容。
我尝试过这段代码
foreach($row['first_information'] as $first)
echo $first;
但只显示'12',这是数组的第二个元素。
提前谢谢。
答案 0 :(得分:1)
你做错了什么(没有显示,可能是错误的var)。以下代码按预期工作(http://codepad.org/NDxhEBdY):
$row = array(
'first_information' => Array(10,12),
'rows' => 1,
0 => Array(
'data_1' => 1,
'data_2' => 2,
'data_3' => 3,
'data_4' => 4,
'data_5' => 5
)
);
foreach($row['first_information'] as $first)
echo $first;