我想查询数组:
Array ( [0] => Array
( [0] => Array ([cid] => 12 [sid] => 1 [category_name] => กาแฟ [mid] => 7 [menu_name] => เอสเพรสโซ่ (ร้อน) [price] => 50 )
[1] => Array ( [cid] => 12 [sid] => 1 [category_name] => กาแฟ [mid] => 9 [menu_name] => มอคค่า (ร้อน) [price] => 50 )
)
[1] =>Array ( [0]=> Array ( [cid] => 14 [sid] => 1 [category_name] => โกโก้ & ชา [mid] => 8 [menu_name] => โกโก้ (เย็น) [price] => 60 )
)
答案 0 :(得分:1)
我不确定你的意思,但我相信你试图从数组中获取数据以插入ui标签。这就是我在MVC中要做的事情:
查看:
<li class="tab" id=""><a href="#<?php echo $variable; ?>">Test</a></li>
<li class="tab" id=""><a href="#<?php echo $variable; ?>">Test</a></li>
<li class="tab" id=""><a href="#<?php echo $variable; ?>">Test</a></li>
<li class="tab" id=""><a href="#<?php echo $variable; ?>">Test</a></li>
<li class="tab" id=""><a href="#<?php echo $variable; ?>">Test</a></li>
控制器:
function expand_staff_info($staff_info) {
$data = $this->Model_request->getData();
$this->load->view('agents/view_staff_info', $data);
}
型号:
function getData() {
$array = array(..... YOUR ARRAY ......);
$data;
foreach ($array as $row) {
foreach ($row as $key => $val) {
$data[$key] = $val;
}
}
return $data;
}