3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ 0 => 'Apple', 2 => 'Orange', 5 => 'Pear', 8 => 'Pear' ]; $result = []; for ( $i = 0, $last = array_key_last($array); $i <= $last; ++$i ) { $result[$i] = $array[$i] ?? null; } var_export($result); echo "\n---\n"; var_export( array_replace( array_fill(0, array_key_last($array), null), $array ) );
Output for git.master, git.master_jit, rfc.property-hooks
array ( 0 => 'Apple', 1 => NULL, 2 => 'Orange', 3 => NULL, 4 => NULL, 5 => 'Pear', 6 => NULL, 7 => NULL, 8 => 'Pear', ) --- array ( 0 => 'Apple', 1 => NULL, 2 => 'Orange', 3 => NULL, 4 => NULL, 5 => 'Pear', 6 => NULL, 7 => NULL, 8 => 'Pear', )

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