3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ "prefix1 foo", "prefix2 bar", "prefix1 aaa", "prefix2 bbb", "prefix3 ccc", "prefix1 111", "prefix2 222" ]; foreach ($array as $v) { [$prefix, $value] = explode(' ', $v, 2); if (isset($batch[$prefix])) { $result[] = $batch; $batch = [$prefix => $value]; } else{ $batch[$prefix] = $value; } } $result[] = $batch; var_export($result);
Output for git.master_jit, git.master, rfc.property-hooks
array ( 0 => array ( 'prefix1' => 'foo', 'prefix2' => 'bar', ), 1 => array ( 'prefix1' => 'aaa', 'prefix2' => 'bbb', 'prefix3' => 'ccc', ), 2 => array ( 'prefix1' => '111', 'prefix2' => '222', ), )

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:
56.07 ms | 402 KiB | 8 Q