3v4l.org

run code in 300+ PHP versions simultaneously
<?php $results = [ [ 'id' => '1000', 'name' => 'Nurten', 'pId' => '26', 'anzahl' => '1', 'pName' => 'Fitness-Teller', 'preis' => '12.90', ], [ 'id' => '1001', 'name' => 'Kutscha', 'pId' => '94', 'anzahl' => '1', 'pName' => 'Pizza Parma', 'preis' => '12.90', ], [ 'id' => '1001', 'name' => 'Kutscha', 'pId' => '75', 'anzahl' => '1', 'pName' => 'Pizza Margherita', 'preis' => '6.50', ], ]; $out = []; foreach ($results as $result) { if (!isset($out[$result['id']])) { $out[$result['id']] = array_filter($result, function($key) { return in_array($key, ['id','name']); }, ARRAY_FILTER_USE_KEY); } $out[$result['id']]['products'][] = array_filter($result, function($key) { return in_array($key, ['pId','anzahl','pName','preis']); }, ARRAY_FILTER_USE_KEY); } print_r(array_values($out));
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [0] => Array ( [id] => 1000 [name] => Nurten [products] => Array ( [0] => Array ( [pId] => 26 [anzahl] => 1 [pName] => Fitness-Teller [preis] => 12.90 ) ) ) [1] => Array ( [id] => 1001 [name] => Kutscha [products] => Array ( [0] => Array ( [pId] => 94 [anzahl] => 1 [pName] => Pizza Parma [preis] => 12.90 ) [1] => Array ( [pId] => 75 [anzahl] => 1 [pName] => Pizza Margherita [preis] => 6.50 ) ) ) )

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
19.18 ms | 403 KiB | 8 Q