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: