我有多维数组,我得到这样的输出:
Array
(
[Bukit Panjang LRT] => Array
(
[0] => Array
(
[station_name] => Senja (BP13)
)
[1] => Array
(
[station_name] => Ten Mile Junction (BP14)
)
)
[Changi Airport Branch Line (CAL)] => Array
(
[2] => Array
(
[station_name] => Changi Airport (CG2)
)
[3] => Array
(
[station_name] => Expo (CG1 / DT35)
)
)
)
我的 foreach 循环:
$level_keys = array();
foreach ($mrtlrt_line as $k => $sub_array){
$this_level = $sub_array['header_name'];
$level_keys[$this_level][$k] = array('station_name' => $sub_array['station_name']);
}
我想像这样在 HTML 元素中显示值:
<h4>Bukit Panjang LRT</h4> <div>
<label class="label_check">
<input name="line" value="1" type="checkbox" />Senja (BP13
</label>
<label class="label_check">
<input name="line" value="2" type="checkbox" />Ten Mile Junction (BP14)
</label> </div>
<h4>Changi Airport Branch Line (CAL)</h4> <div>
<label class="label_check">
<input name="line" value="1" type="checkbox" />Changi Airport (CG2)
</label>
<label class="label_check">
<input name="line" value="2" type="checkbox" />Expo (CG1 / DT35)
</label> </div>
有什么想法或建议吗?谢谢。