PHP output table

Source: Internet
Author: User
Existing data is as follows: large bag cup DPK219VAC0011.00 small bag large cup DPK219VBW0011.00 pot of crab meat 1 pound tank RCN061-1VAC0012.00 pot of crab meat 1 pound pot of RCN061-1VBW0012.00 meat 5 mmrfb300-2vb... the existing data is as follows:

Renew bag mug DPK219 VAC001 1.00
Renew bag mug DPK219 VBW001 1.00
Pot of crab meat 1 lb/tank RCN061-1 VAC001 2.00
1 pound/pot RCN061-1 VBW001 2.00
Strip 5mm RFB300-2 VAC001 3.00
Premium strip 5mm RFB300-2 VBW001 3.00
RFB300-3 VAC001 4.00
RFB300-3 VBW001 4.00

The requirement is to output a table (similar to excel). All the information of the same product is output in one row. There are four rows in total, as shown below:

Extra bag mug 1.00 1.00
1 lb/2.00 2.00
Niu Lin film 5mm 3.00 3.00
Thick Niu Lin film 4.00 4.00

Don't blame cainiao.

Reply content:

The existing data is as follows:

Renew bag mug DPK219 VAC001 1.00
Renew bag mug DPK219 VBW001 1.00
Pot of crab meat 1 lb/tank RCN061-1 VAC001 2.00
1 pound/pot RCN061-1 VBW001 2.00
Strip 5mm RFB300-2 VAC001 3.00
Premium strip 5mm RFB300-2 VBW001 3.00
RFB300-3 VAC001 4.00
RFB300-3 VBW001 4.00

The requirement is to output a table (similar to excel). All the information of the same product is output in one row. There are four rows in total, as shown below:

Extra bag mug 1.00 1.00
1 lb/2.00 2.00
Niu Lin film 5mm 3.00 3.00
Thick Niu Lin film 4.00 4.00

Don't blame cainiao.

In order to give you an example, it will be mixed up.


  'Fill bag cup ', 'typea' => 'dpk219', 'typeb' => 'vac001', 'price' => '1. 00'), array ('catoggary '=> 'character bag mug', 'typea' => 'dpk219 ', 'typeb' => 'vbw001 ', 'price' => '1. 00'), array ('catoggary '=> 'canned crab meat', 'typea' => 'rcn061-1', 'typeb' => 'vac001 ', 'price' => '2. 00'), array ('catoggary '=> 'canned crab meat', 'typea' => 'rcn061-1', 'typeb' => 'vbw001 ', 'price' => '2. 00'), array ('catoggary '=> 'nougat 100', 'typea' => 'rfb300-2',' t Ypeb' => 'vac001', 'price' => '3. 00'), array ('catoggary '=> 'nougat 100', 'typea' => 'rfb300-2', 'typeb' => 'vbw001 ', 'price' => '3. 00'), array ('catoggary '=> 'thick Niu line', 'typea' => 'rfb300-3', 'typeb' => 'vac001 ', 'price' => '4. 00'), array ('catoggary '=> 'thick Niu line', 'typea' => 'rfb300-3', 'typeb' => 'vbw001 ', 'price' => '4. 00'),); $ tableInfo = array (); // $ tableInfo = array_column ($ info, 'catoggary ', 'price ');/ /If php version> 5.5 foreach ($ info as $ item) $ tableInfo [$ item ['catogary'] = $ item ['price'];?>

In general, we will first put the data in an array.infoAnd then filter the array to retrieve the useful data that needs to be displayed in the table to a new array.tableInfo. Next, traverse the new array and output the data to 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.