3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array ( 'parent_id' => array ( 9 => array ( 0 => 12 ), 20 => array ( 0 => 25, 1 => 22 ), 21 => array ( 0 => 23, 1 => 24 ) ) ); // re-index to 0 $array = array_values($array['parent_id']); // sort so the longest arrays are first usort($array, function ($a, $b) { return count($b) - count($a); }); // output array $pairs = array(); for ($i = 0; $i < count($array) - 1; $i += 2) { for ($j = 0; $j < min(count($array[$i]), count($array[$i+1])); $j++) { $pairs[] = array($array[$i][$j], $array[$i+1][$j]); } } print_r($pairs);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [0] => Array ( [0] => 25 [1] => 23 ) [1] => Array ( [0] => 22 [1] => 24 ) )

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:
114.69 ms | 405 KiB | 5 Q