3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [10, -1, -1, -1, -1, 15, 16, 17, -1, -1, 20]; $result = []; foreach ($array as $v) { if ($v === -1) { unset($ref); continue; } if (!isset($ref)) { $result[] =& $ref; } $ref[] = $v; } var_export($result);
Output for git.master_jit, git.master
array ( 0 => array ( 0 => 10, ), 1 => array ( 0 => 15, 1 => 16, 2 => 17, ), 2 => array ( 0 => 20, ), )

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:
61.13 ms | 987 KiB | 4 Q