3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [ "name" => [ "ajay", "ajay2", ], "email" => [ "a@g.com", "a@g.com2", ], "phone" => [ "23423423", "234234232", ], "address" => [ "sdfghj", "ertyu", ], "date" => 123456 ]; $keys = array_keys($arr); $maxLength = count(max($arr)); //fix array $arr = array_map(function($v)use($maxLength){ if(!is_array($v)) return array_fill(0, $maxLength, $v); elseif(count($v) < $maxLength) return array_fill(0, $maxLength, $v[0]); return $v; }, $arr); //transpose array_unshift($arr, NULL); $arr = call_user_func_array("array_map", $arr); //add keys $arr = array_map(function($v)use($keys){ return array_combine($keys, $v); }, $arr); print_r($arr);
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught ArgumentCountError: array_map() expects at least 2 arguments, 1 given in /in/fEGrg:42 Stack trace: #0 /in/fEGrg(42): array_map(NULL, name: Array, email: Array, phone: Array, address: Array, date: Array) #1 {main} thrown in /in/fEGrg on line 42
Process exited with code 255.

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