时间:2021-07-01 10:21:17 帮助过:30人阅读
数据结构如下:
array (size=6)
0 =>
array (size=9)
'orde_id' => string '154' (length=3)
'orde_sn' => string 'aaaa' (length=12)
'orde_menu_date' => string '2016414' (length=10)
'orde_dinner_time' => string '0' (length=1)
'orde_status' => string '0' (length=1)
'orde_dish_id' => string '12' (length=2)
'orde_sauc_id' => string '2' (length=1)
'dish_name' => string '地中海水果沙拉' (length=21)
'sauc_name' => string '北京甜面酱' (length=15)
1 =>
array (size=9)
'orde_id' => string '155' (length=3)
'orde_sn' => string 'bbbbb' (length=32)
'orde_menu_date' => string '2016414' (length=10)
'orde_dinner_time' => string '0' (length=1)
'orde_status' => string '0' (length=1)
'orde_dish_id' => string '12' (length=2)
'orde_sauc_id' => string '2' (length=1)
'dish_name' => string '地中海水果沙拉' (length=21)
'sauc_name' => string '北京甜面酱' (length=15)
2 =>
array (size=9)
'orde_id' => string '149' (length=3)
'orde_sn' => string 'aaaaa' (length=32)
'orde_menu_date' => string '2016414' (length=10)
'orde_dinner_time' => string '1' (length=1)
'orde_status' => string '0' (length=1)
'orde_dish_id' => string '9' (length=1)
'orde_sauc_id' => string '0' (length=1)
'dish_name' => string '红烧肉' (length=9)
'sauc_name' => null
3 =>
array (size=9)
'orde_id' => string '151' (length=3)
'orde_sn' => string 'aaaaa' (length=32)
'orde_menu_date' => string '2016415' (length=10)
'orde_dinner_time' => string '0' (length=1)
'orde_status' => string '0' (length=1)
'orde_dish_id' => string '1' (length=1)
'orde_sauc_id' => string '0' (length=1)
'dish_name' => string '鱼香肉丝' (length=12)
'sauc_name' => null
4 =>
array (size=9)
'orde_id' => string '153' (length=3)
'orde_sn' => string 'aaaaa' (length=32)
'orde_menu_date' => string '2016415' (length=10)
'orde_dinner_time' => string '0' (length=1)
'orde_status' => string '0' (length=1)
'orde_dish_id' => string '1' (length=1)
'orde_sauc_id' => string '0' (length=1)
'dish_name' => string '鱼香肉丝' (length=12)
'sauc_name' => null
5 =>
array (size=9)
'orde_id' => string '152' (length=3)
'orde_sn' => string 'aaaaa' (length=32)
'orde_menu_date' => string '2016415' (length=10)
'orde_dinner_time' => string '0' (length=1)
'orde_status' => string '0' (length=1)
'orde_dish_id' => string '13' (length=2)
'orde_sauc_id' => string '0' (length=1)
'dish_name' => string '羊肉泡馍' (length=12)
'sauc_name' => null
输出示意如下:
2016-4-14 午餐
单号:aaaaa
地中海水果沙拉(北京甜面酱) x1
单号:bbbbb
地中海水果沙拉(北京甜面酱) x1
2016-4-14 晚餐
单号:aaaaa
红烧肉 x1
2016-4-15 午餐
单号:aaaaa
鱼香肉丝 x2
羊肉泡馍 x1
小弟纠结这个问题已经一天有余,实在是脑力不够,求tp大拿帮忙,不胜感激!问题如下:
使用tp的过程中,取出如下数据结构,想在模版页面输出,输出的时候需要按照orde_menu_date和orde_dinner_time为第一维,orde_sn为第二维,orde_dish_id和orde_sauce_id为第三维来循环输出,请问如何重新组织数据结构?
数据结构如下:
array (size=6)
0 =>
array (size=9)
'orde_id' => string '154' (length=3)
'orde_sn' => string 'aaaa' (length=12)
'orde_menu_date' => string '2016414' (length=10)
'orde_dinner_time' => string '0' (length=1)
'orde_status' => string '0' (length=1)
'orde_dish_id' => string '12' (length=2)
'orde_sauc_id' => string '2' (length=1)
'dish_name' => string '地中海水果沙拉' (length=21)
'sauc_name' => string '北京甜面酱' (length=15)
1 =>
array (size=9)
'orde_id' => string '155' (length=3)
'orde_sn' => string 'bbbbb' (length=32)
'orde_menu_date' => string '2016414' (length=10)
'orde_dinner_time' => string '0' (length=1)
'orde_status' => string '0' (length=1)
'orde_dish_id' => string '12' (length=2)
'orde_sauc_id' => string '2' (length=1)
'dish_name' => string '地中海水果沙拉' (length=21)
'sauc_name' => string '北京甜面酱' (length=15)
2 =>
array (size=9)
'orde_id' => string '149' (length=3)
'orde_sn' => string 'aaaaa' (length=32)
'orde_menu_date' => string '2016414' (length=10)
'orde_dinner_time' => string '1' (length=1)
'orde_status' => string '0' (length=1)
'orde_dish_id' => string '9' (length=1)
'orde_sauc_id' => string '0' (length=1)
'dish_name' => string '红烧肉' (length=9)
'sauc_name' => null
3 =>
array (size=9)
'orde_id' => string '151' (length=3)
'orde_sn' => string 'aaaaa' (length=32)
'orde_menu_date' => string '2016415' (length=10)
'orde_dinner_time' => string '0' (length=1)
'orde_status' => string '0' (length=1)
'orde_dish_id' => string '1' (length=1)
'orde_sauc_id' => string '0' (length=1)
'dish_name' => string '鱼香肉丝' (length=12)
'sauc_name' => null
4 =>
array (size=9)
'orde_id' => string '153' (length=3)
'orde_sn' => string 'aaaaa' (length=32)
'orde_menu_date' => string '2016415' (length=10)
'orde_dinner_time' => string '0' (length=1)
'orde_status' => string '0' (length=1)
'orde_dish_id' => string '1' (length=1)
'orde_sauc_id' => string '0' (length=1)
'dish_name' => string '鱼香肉丝' (length=12)
'sauc_name' => null
5 =>
array (size=9)
'orde_id' => string '152' (length=3)
'orde_sn' => string 'aaaaa' (length=32)
'orde_menu_date' => string '2016415' (length=10)
'orde_dinner_time' => string '0' (length=1)
'orde_status' => string '0' (length=1)
'orde_dish_id' => string '13' (length=2)
'orde_sauc_id' => string '0' (length=1)
'dish_name' => string '羊肉泡馍' (length=12)
'sauc_name' => null
输出示意如下:
2016-4-14 午餐
单号:aaaaa
地中海水果沙拉(北京甜面酱) x1
单号:bbbbb
地中海水果沙拉(北京甜面酱) x1
2016-4-14 晚餐
单号:aaaaa
红烧肉 x1
2016-4-15 午餐
单号:aaaaa
鱼香肉丝 x2
羊肉泡馍 x1
楼主是想把相同日期且相同产品的订单分成组是吧?这样的话就要循环查询出来的订单,重新构建数组了。
试了一下,不知道是不是你想要的。 (代码有点low 见谅)
$arr = 你的数据;
$data = array();
$a = 0;
$data[$a]['orde_sn'][0] = $arr[0]['orde_sn'];
$data[$a]['orde_menu_date'] = $arr[0]['orde_menu_date'];
$data[$a]['dish_name'][0] = $arr[0]['dish_name'];
$data[$a]['sauc_name'][0] = $arr[0]['sauc_name'];
for($i=1; $i
分组......