Array-thinkphp data structure of the organization output problem, ask TP Danale help, greatly appreciated!

Source: Internet
Author: User
Keywords thinkphp php array
Little brother Tangled This problem has been more than a day, it is not enough brainpower, ask TP Danale help, greatly appreciated! The problem is as follows:
Use TP process, take out the following data structure, want to output in the template page, the output needs to follow orde_menu_date and Orde_dinner_time as the first dimension, ORDE_SN for the second dimension, orde_dish_id and Orde_sauce_ ID is the third Bellavita loop output, how can I reorganize the data structure?

The data structure is as follows:
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

The output is as follows:

2016-4-14 Lunch
Waybill: AAAAA
Mediterranean Fruit salad (Beijing sweet sauce) x1

Waybill: BBBBB
Mediterranean Fruit salad (Beijing sweet sauce) x1

2016-4-14 Dinner
Waybill: AAAAA
Braised Pork x1

2016-4-15 Lunch
Waybill: AAAAA
Fish fragrant Shredded Pork x2
Lamb Paomo x1

Reply content:

Little brother Tangled This problem has been more than a day, it is not enough brainpower, ask TP Danale help, greatly appreciated! The problem is as follows:
Use TP process, take out the following data structure, want to output in the template page, the output needs to follow orde_menu_date and Orde_dinner_time as the first dimension, ORDE_SN for the second dimension, orde_dish_id and Orde_sauce_ ID is the third Bellavita loop output, how can I reorganize the data structure?

The data structure is as follows:
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

The output is as follows:

2016-4-14 Lunch
Waybill: AAAAA
Mediterranean Fruit salad (Beijing sweet sauce) x1

Waybill: BBBBB
Mediterranean Fruit salad (Beijing sweet sauce) x1

2016-4-14 Dinner
Waybill: AAAAA
Braised Pork x1

2016-4-15 Lunch
Waybill: AAAAA
Fish fragrant Shredded Pork x2
Lamb Paomo x1

Landlord is want to put the same date and the same product orders into groups, right? In this case, we need to iterate over the order of the query and rebuild the array.

Try it, don't know if it's what you want. (The code is a bit low forgive)

  $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 ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.