3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ ['brand' => 'ABC', 'model' => 'xyz', 'size' => 13], ['brand' => 'QWE', 'model' => 'poi', 'size' => 23], ['brand' => 'ABC', 'model' => 'xyz', 'size' => 18] ]; var_export( array_values( array_reduce( $array, function ($carry, $row) { $compositeKey = $row['brand'] . '_' . $row['model']; if (!isset($carry[$compositeKey])) { $carry[$compositeKey] = $row; } else { $carry[$compositeKey]['size'] = array_merge( (array)$carry[$compositeKey]['size'], [$row['size']] ); } return $carry; } ) ) );
Output for git.master, git.master_jit, rfc.property-hooks
array ( 0 => array ( 'brand' => 'ABC', 'model' => 'xyz', 'size' => array ( 0 => 13, 1 => 18, ), ), 1 => array ( 'brand' => 'QWE', 'model' => 'poi', 'size' => 23, ), )

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:
28.14 ms | 406 KiB | 5 Q