3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $array['dump'] = 'dump'; $array['ids'] = array( 2 => array( 'id' => 1, 'val' => 'one'), 'delete' => 3, 1 => array( 'id' => 2, 'val' => 'two'), 0 => array( 'id' => 3, 'val' => 'three')); unset($array['ids']['delete']); foreach( $array['ids'] as $index => &$ids ) { if( $index == 2 ) { $ids['new'] = $ids['val']; } else { $ids['new'] = ''; } } print_r($array); $array['ids'] = array_values($array['ids']); print_r($array);
Output for 5.0.0 - 7.1.0
Array ( [dump] => dump [ids] => Array ( [2] => Array ( [id] => 1 [val] => one [new] => one ) [1] => Array ( [id] => 2 [val] => two [new] => ) [0] => Array ( [id] => 3 [val] => three [new] => ) ) ) Array ( [dump] => dump [ids] => Array ( [0] => Array ( [id] => 1 [val] => one [new] => one ) [1] => Array ( [id] => 2 [val] => two [new] => ) [2] => Array ( [id] => 3 [val] => three [new] => ) ) )
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected '&', expecting T_VARIABLE or '$' in /in/nt22A on line 8
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected '&', expecting T_VARIABLE or '$' in /in/nt22A on line 8
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_VARIABLE' or `'$'' in /in/nt22A on line 8
Process exited with code 255.