3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = [ 'name' => [ 'Ace', 'James', 'Tommy' ], 'age' => [ 10, 20, 32 ] ]; $newData = []; function recursivelyFormat($data) { $newData = []; if (count($data) > 0) { $name = array_shift($data['name']); $age = array_shift($data['age']); $newData[] = [ 'name' => $name, 'age' => $age ]; recursivelyFormat($data); } return $newData; } var_dump(recursivelyFormat($data)); /*for ($i = 0; $i < count($data['name']); $i++) { $d = [ 'name' => $data['name'][$i], 'age' => $data['age'][$i] ]; $newData[] = $d; } $mainData = [ 'people' => $newData ];*/ //var_dump($mainData);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RXgb6
function name:  (null)
number of ops:  9
compiled vars:  !0 = $data, !1 = $newData
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   16     1        ASSIGN                                                   !1, <array>
   36     2        INIT_FCALL                                               'var_dump'
          3        INIT_FCALL                                               'recursivelyformat'
          4        SEND_VAR                                                 !0
          5        DO_FCALL                                      0  $4      
          6        SEND_VAR                                                 $4
          7        DO_ICALL                                                 
   51     8      > RETURN                                                   1

Function recursivelyformat:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 22
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
filename:       /in/RXgb6
function name:  recursivelyFormat
number of ops:  24
compiled vars:  !0 = $data, !1 = $newData, !2 = $name, !3 = $age
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
   19     1        ASSIGN                                                   !1, <array>
   21     2        COUNT                                            ~5      !0
          3        IS_SMALLER                                               0, ~5
          4      > JMPZ                                                     ~6, ->22
   22     5    >   INIT_FCALL                                               'array_shift'
          6        FETCH_DIM_W                                      $7      !0, 'name'
          7        SEND_REF                                                 $7
          8        DO_ICALL                                         $8      
          9        ASSIGN                                                   !2, $8
   23    10        INIT_FCALL                                               'array_shift'
         11        FETCH_DIM_W                                      $10     !0, 'age'
         12        SEND_REF                                                 $10
         13        DO_ICALL                                         $11     
         14        ASSIGN                                                   !3, $11
   26    15        INIT_ARRAY                                       ~14     !2, 'name'
   27    16        ADD_ARRAY_ELEMENT                                ~14     !3, 'age'
   25    17        ASSIGN_DIM                                               !1
   27    18        OP_DATA                                                  ~14
   30    19        INIT_FCALL_BY_NAME                                       'recursivelyFormat'
         20        SEND_VAR_EX                                              !0
         21        DO_FCALL                                      0          
   33    22    > > RETURN                                                   !1
   34    23*     > RETURN                                                   null

End of function recursivelyformat

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.49 ms | 1399 KiB | 18 Q