PHP output table

Source: Internet
Author: User
The existing data is as follows:

Bread Cup DPK219 VAC001 1.00
Bread Cup DPK219 VBW001 1.00
Canned crab meat 1 lbs/can rcn061-1 VAC001 2.00
Canned crab meat 1 lbs/can rcn061-1 VBW001 2.00
5mm rfb300-2 VAC001 3.00
5mm rfb300-2 VBW001 3.00
Thick Beef rfb300-3 VAC001 4.00
Thick Beef rfb300-3 VBW001 4.00

The requirement is to output a table (similar to Excel), and the information for all the same products is output in a row, altogether four lines, as follows:

Bread Cup 1.00 1.00
Canned crab meat 1 lbs/can 2.00 2.00
Sliced Beef 5mm 3.00 3.00
Thick Beef Shower 4.00 4.00

Rookie dish problem, do not blame.

Reply content:

The existing data is as follows:

Bread Cup DPK219 VAC001 1.00
Bread Cup DPK219 VBW001 1.00
Canned crab meat 1 lbs/can rcn061-1 VAC001 2.00
Canned crab meat 1 lbs/can rcn061-1 VBW001 2.00
5mm rfb300-2 VAC001 3.00
5mm rfb300-2 VBW001 3.00
Thick Beef rfb300-3 VAC001 4.00
Thick Beef rfb300-3 VBW001 4.00

The requirement is to output a table (similar to Excel), and the information for all the same products is output in a row, altogether four lines, as follows:

Bread Cup 1.00 1.00
Canned crab meat 1 lbs/can 2.00 2.00
Sliced Beef 5mm 3.00 3.00
Thick Beef Shower 4.00 4.00

Rookie dish problem, do not blame.

In order to give you an example of the mixed.


   ' Bread cups ', ' typea ' = ' DPK219 ', ' typeb ' = ' VAC001 ', ' price ' = ' 1.00 '), Array (' catogary ' = ' "bread cups ', ' Typ EA ' = ' DPK219 ', ' typeb ' = ' VBW001 ', ' price ' = ' 1.00 '), Array (' catogary ' = ' canned crab meat ', ' typea ' = ' R ') Cn061-1 ', ' typeb ' = ' VAC001 ', ' price ' = ' 2.00 '), Array (' catogary ' = ' can be crab meat ', ' typea ' = ' rcn061-1 ', ' TypeB ' = ' VBW001 ', ' price ' = ' 2.00 '), Array (' catogary ' + ' ox shower 5mm ', ' typea ' = ' rfb300-2 ', ' typeb ' = > ' VAC001 ', ' price ' = ' 3.00 '), Array (' catogary ' + ' ox shower 5mm ', ' typea ' = ' rfb300-2 ', ' typeb ' = ' VBW ') 001 ', ' price ' = ' 3.00 '), Array (' catogary ' and ' thick-topped ', ' typea ' = ' rfb300-3 ', ' typeb ' = ' VAC001 ', ' pric ' E ' = ' = ' 4.00 '), Array (' catogary ' = ' thick-topped ', ' typea ' = ' rfb300-3 ', ' typeb ' = ' VBW001 ', ' price ' = ' 4    .00 '),);    $tableInfo = Array (); $tableInfo = Array_column ($info, ' catogary ', ' price ');//if php version > 5.5 foreach ($info as $iTEM) $tableInfo [$item [' catogary ']] = $item [' Price '];?     >

In general, the idea is to put the data in an array info , then filter the arrays, and take out the useful data that needs to be shown in the table into a new array tableInfo . Next, traverse the new array to output the data into the table table . As follows:

  • $price) {?>

    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.