3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ 0 => 'Apple', 2 => 'Orange', 5 => 'Pear', 8 => 'Pear' ]; var_export( array_fill(0, array_key_last($array), null) + $array ); echo "\n---\n"; var_export( $array + array_fill(0, array_key_last($array), null) ); echo "\n---\n"; var_export( array_merge( array_fill(0, array_key_last($array), null), $array ) );
Output for git.master, git.master_jit, rfc.property-hooks
array ( 0 => NULL, 1 => NULL, 2 => NULL, 3 => NULL, 4 => NULL, 5 => NULL, 6 => NULL, 7 => NULL, 8 => 'Pear', ) --- array ( 0 => 'Apple', 2 => 'Orange', 5 => 'Pear', 8 => 'Pear', 1 => NULL, 3 => NULL, 4 => NULL, 6 => NULL, 7 => NULL, ) --- array ( 0 => NULL, 1 => NULL, 2 => NULL, 3 => NULL, 4 => NULL, 5 => NULL, 6 => NULL, 7 => NULL, 8 => 'Apple', 9 => 'Orange', 10 => 'Pear', 11 => '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:
26.72 ms | 406 KiB | 5 Q