3v4l.org

run code in 300+ PHP versions simultaneously
<?php $info = array( array('catogary' => '麵包紙杯', 'typeA' => 'DPK219', 'typeB' => 'VAC001', 'price' => '1.00'), array('catogary' => '麵包紙杯', 'typeA' => 'DPK219', 'typeB' => 'VBW001', 'price' => '1.00'), array('catogary' => '罐裝蟹肉 ', 'typeA' => 'RCN061-1', 'typeB' => 'VAC001', 'price' => '2.00'), array('catogary' => '罐裝蟹肉 ', 'typeA' => 'RCN061-1', 'typeB' => 'VBW001', 'price' => '2.00'), array('catogary' => '牛淋片5mm', 'typeA' => 'RFB300-2', 'typeB' => 'VAC001', 'price' => '3.00'), array('catogary' => '牛淋片5mm', 'typeA' => 'RFB300-2', 'typeB' => 'VBW001', 'price' => '3.00'), array('catogary' => '厚牛淋片', 'typeA' => 'RFB300-3', 'typeB' => 'VAC001', 'price' => '4.00'), array('catogary' => '厚牛淋片', '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']; ?> <table> <?php foreach($tableInfo as $catogary => $price) { ?> <tr> <td><?=$catogary?></td> <td><?=$price?></td> <td><?=$price?></td> </tr> </tbale> <?php }

preferences:
37.91 ms | 402 KiB | 5 Q