3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [ 'name' => ['a', 'b', 'c'], 'age' => [ 2 , 1 , 3 , 4 ], 'shoe' => [11 , 9 ], 'kids' => [ 1 , 0 , 2 ] ]; $keys = array_keys($arr); $transposed = array_map(null, ...array_values($arr)); foreach ($transposed as &$subarray) { $subarray = array_combine($keys, $subarray); } var_export($transposed);
Output for git.master, git.master_jit, rfc.property-hooks
array ( 0 => array ( 'name' => 'a', 'age' => 2, 'shoe' => 11, 'kids' => 1, ), 1 => array ( 'name' => 'b', 'age' => 1, 'shoe' => 9, 'kids' => 0, ), 2 => array ( 'name' => 'c', 'age' => 3, 'shoe' => NULL, 'kids' => 2, ), 3 => array ( 'name' => NULL, 'age' => 4, 'shoe' => NULL, 'kids' => NULL, ), )

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:
64.5 ms | 402 KiB | 8 Q