3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input = array( 0 => 'fruit', 1 => 'apple', 2 => 'vegetable', 3 => 'corn', ); /* remove last item from odd arrays */ if( count( $input ) % 2 != 0 ) { array_pop( $input ); } $output = array(); $inputLength = count( $input ); for( $i = 0; $i < $inputLength; $i = $i + 2 ) { $output[$input[$i]] = $input[$i + 1]; } var_dump( $output );
Output for git.master, git.master_jit, rfc.property-hooks
array(2) { ["fruit"]=> string(5) "apple" ["vegetable"]=> string(4) "corn" }

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:
41.06 ms | 401 KiB | 8 Q