3v4l.org

run code in 500+ PHP versions simultaneously
<?php $arrayA = [ ["sentence" => "Hello world", "nextSpeaker" => 0], ["sentence" => "Hello world again", "nextSpeaker" => 1], ["sentence" => "Hello world twice!", "nextSpeaker" => 1], ]; $arrayB = [ ["sentence" => "Bye world", "nextSpeaker" => 1], ["sentence" => "Bye world again", "nextSpeaker" => 0], ["sentence" => "Bye world twice", "nextSpeaker" => 0], ]; $arrays = [$arrayA, $arrayB]; $pullFrom = 0; $result = []; while ($arrays[0] && $arrays[1]) { $result[] = $row = array_shift($arrays[$pullFrom]); $pullFrom = $row['nextSpeaker'] ? 1 - $pullFrom : $pullFrom; } var_export(array_merge($result, ...$arrays));
Output for rfc.property-hooks, git.master, git.master_jit
array ( 0 => array ( 'sentence' => 'Hello world', 'nextSpeaker' => 0, ), 1 => array ( 'sentence' => 'Hello world again', 'nextSpeaker' => 1, ), 2 => array ( 'sentence' => 'Bye world', 'nextSpeaker' => 1, ), 3 => array ( 'sentence' => 'Hello world twice!', 'nextSpeaker' => 1, ), 4 => array ( 'sentence' => 'Bye world again', 'nextSpeaker' => 0, ), 5 => array ( 'sentence' => 'Bye world twice', 'nextSpeaker' => 0, ), )

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:
33.5 ms | 1360 KiB | 4 Q