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);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fEGrg
function name:  (null)
number of ops:  37
compiled vars:  !0 = $arr, !1 = $keys, !2 = $maxLength
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   28     1        INIT_FCALL                                               'array_keys'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $4      
          4        ASSIGN                                                   !1, $4
   29     5        INIT_FCALL                                               'max'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $6      
          8        COUNT                                            ~7      $6
          9        ASSIGN                                                   !2, ~7
   32    10        INIT_FCALL                                               'array_map'
         11        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FfEGrg%3A32%240'
         12        BIND_LEXICAL                                             ~9, !2
   38    13        SEND_VAL                                                 ~9
         14        SEND_VAR                                                 !0
         15        DO_ICALL                                         $10     
   32    16        ASSIGN                                                   !0, $10
   41    17        INIT_FCALL                                               'array_unshift'
         18        SEND_REF                                                 !0
         19        SEND_VAL                                                 null
         20        DO_ICALL                                                 
   42    21        INIT_FCALL                                               'array_map'
         22        SEND_ARRAY                                               !0
         23        CHECK_UNDEF_ARGS                                         
         24        DO_FCALL                                      0  $13     
         25        ASSIGN                                                   !0, $13
   45    26        INIT_FCALL                                               'array_map'
         27        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FfEGrg%3A45%241'
         28        BIND_LEXICAL                                             ~15, !1
   48    29        SEND_VAL                                                 ~15
         30        SEND_VAR                                                 !0
         31        DO_ICALL                                         $16     
   45    32        ASSIGN                                                   !0, $16
   50    33        INIT_FCALL                                               'print_r'
         34        SEND_VAR                                                 !0
         35        DO_ICALL                                                 
         36      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FfEGrg%3A32%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 12
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 22
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fEGrg
function name:  {closure}
number of ops:  24
compiled vars:  !0 = $v, !1 = $maxLength
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   33     2        TYPE_CHECK                                  128  ~2      !0
          3        BOOL_NOT                                         ~3      ~2
          4      > JMPZ                                                     ~3, ->12
   34     5    >   INIT_FCALL                                               'array_fill'
          6        SEND_VAL                                                 0
          7        SEND_VAR                                                 !1
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                         $4      
         10      > RETURN                                                   $4
         11*       JMP                                                      ->22
   35    12    >   COUNT                                            ~5      !0
         13        IS_SMALLER                                               ~5, !1
         14      > JMPZ                                                     ~6, ->22
   36    15    >   INIT_FCALL                                               'array_fill'
         16        SEND_VAL                                                 0
         17        SEND_VAR                                                 !1
         18        FETCH_DIM_R                                      ~7      !0, 0
         19        SEND_VAL                                                 ~7
         20        DO_ICALL                                         $8      
         21      > RETURN                                                   $8
   37    22    > > RETURN                                                   !0
   38    23*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FfEGrg%3A32%240

Function %00%7Bclosure%7D%2Fin%2FfEGrg%3A45%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fEGrg
function name:  {closure}
number of ops:  8
compiled vars:  !0 = $v, !1 = $keys
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   45     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   46     2        INIT_FCALL                                               'array_combine'
          3        SEND_VAR                                                 !1
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $2      
          6      > RETURN                                                   $2
   48     7*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FfEGrg%3A45%241

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
179.38 ms | 1405 KiB | 27 Q