I have been entangled in this problem for more than a day, but I am really not mentally competent. I am very grateful to you for your help! The problem is as follows: In the process of using tp, the following data structure is taken out. To output the data on the template page, the orde_menu_date and orde_dinner_time must be the first dimension, orde _... I have been entangled in this problem for more than a day, but I am really not mentally competent. I am very grateful to you for your help! The problem is as follows:
In the process of using tp, the following data structure is taken out. To output the data on the template page, the orde_menu_date and orde_dinner_time must be the first dimension, and the orde_sn must be the second dimension, orde_dish_id and orde_sauce_id are output cyclically in the third dimension. How can I reorganize the data structure?
The data structure is as follows:
Array (size = 6)
0 =>
Array (size = 9) 'orde _ id' => string '000000' (length = 3) 'orde _ sn '=> string 'aaa' (length = 12) 'orde _ menu_date '=> string '000000' (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 'Mediterranean fruit Sala' (length = 21) 'sauc _ name' => string 'Beijing sweet sauce '(length = 15)
1 =>
Array (size = 9) 'orde _ id' => string '000000' (length = 3) 'orde _ sn '=> string 'bbbbbb' (length = 32) 'orde _ menu_date '=> string '000000' (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 'Mediterranean fruit Sala' (length = 21) 'sauc _ name' => string 'Beijing sweet sauce '(length = 15)
2 =>
Array (size = 9) 'orde _ id' => string '000000' (length = 3) 'orde _ sn '=> string 'aaaaa' (length = 32) 'orde _ menu_date '=> string '000000' (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 'braised pork' (length = 9) 'sauc _ name' => null
3 =>
Array (size = 9) 'orde _ id' => string '000000' (length = 3) 'orde _ sn '=> string 'aaaaa' (length = 32) 'orde _ menu_date '=> string '000000' (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 'shredded fish files' (length = 12) 'sauc _ name' => null
4 =>
Array (size = 9) 'orde _ id' => string '000000' (length = 3) 'orde _ sn '=> string 'aaaaa' (length = 32) 'orde _ menu_date '=> string '000000' (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 'shredded fish files' (length = 12) 'sauc _ name' => null
5 =>
Array (size = 9) 'orde _ id' => string '000000' (length = 3) 'orde _ sn '=> string 'aaaaa' (length = 32) 'orde _ menu_date '=> string '000000' (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 'mutton taobao' (length = 12) 'sauc _ name' => null
The output is as follows:
Lunch
Ticket No.: aaaaa
Mediterranean fruit salad (Beijing sweet Noodle Sauce) x1
Ticket No.: bbbbb
Mediterranean fruit salad (Beijing sweet Noodle Sauce) x1
Dinner
Ticket No.: aaaaa
Braised Pork x1
Lunch
Ticket No.: aaaaa
Fish shredded meat x2
Mutton soup x1
Reply content:
I have been entangled in this problem for more than a day, but I am really not mentally competent. I am very grateful to you for your help! The problem is as follows:
In the process of using tp, the following data structure is taken out. To output the data on the template page, the orde_menu_date and orde_dinner_time must be the first dimension, and the orde_sn must be the second dimension, orde_dish_id and orde_sauce_id are output cyclically in the third dimension. How can I reorganize the data structure?
The data structure is as follows:
Array (size = 6)
0 =>
Array (size = 9) 'orde _ id' => string '000000' (length = 3) 'orde _ sn '=> string 'aaa' (length = 12) 'orde _ menu_date '=> string '000000' (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 'Mediterranean fruit Sala' (length = 21) 'sauc _ name' => string 'Beijing sweet sauce '(length = 15)
1 =>
Array (size = 9) 'orde _ id' => string '000000' (length = 3) 'orde _ sn '=> string 'bbbbbb' (length = 32) 'orde _ menu_date '=> string '000000' (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 'Mediterranean fruit Sala' (length = 21) 'sauc _ name' => string 'Beijing sweet sauce '(length = 15)
2 =>
Array (size = 9) 'orde _ id' => string '000000' (length = 3) 'orde _ sn '=> string 'aaaaa' (length = 32) 'orde _ menu_date '=> string '000000' (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 'braised pork' (length = 9) 'sauc _ name' => null
3 =>
Array (size = 9) 'orde _ id' => string '000000' (length = 3) 'orde _ sn '=> string 'aaaaa' (length = 32) 'orde _ menu_date '=> string '000000' (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 'shredded fish files' (length = 12) 'sauc _ name' => null
4 =>
Array (size = 9) 'orde _ id' => string '000000' (length = 3) 'orde _ sn '=> string 'aaaaa' (length = 32) 'orde _ menu_date '=> string '000000' (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 'shredded fish files' (length = 12) 'sauc _ name' => null
5 =>
Array (size = 9) 'orde _ id' => string '000000' (length = 3) 'orde _ sn '=> string 'aaaaa' (length = 32) 'orde _ menu_date '=> string '000000' (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 'mutton taobao' (length = 12) 'sauc _ name' => null
The output is as follows:
Lunch
Ticket No.: aaaaa
Mediterranean fruit salad (Beijing sweet Noodle Sauce) x1
Ticket No.: bbbbb
Mediterranean fruit salad (Beijing sweet Noodle Sauce) x1
Dinner
Ticket No.: aaaaa
Braised Pork x1
Lunch
Ticket No.: aaaaa
Fish shredded meat x2
Mutton soup x1
I want to divide orders of the same date and product into groups, right? In this case, we need to cyclically query the orders and recreate the array.
I tried it. I don't know if you want it. (The code is a bit low. Sorry)
$ Arr = your data; $ 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
Group ......