3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = ['a' => 1, 'b' => ['c' => 3]]; function recursivelyCreateObjs(array $array) { $obj = new stdClass; foreach($array as $key => $value) { if(is_array($value)) { $obj->$key = recursivelyCreateObjs($value); } else { $obj->$key = $value; } } return $obj; } $obj = recursivelyCreateObjs($array); echo $obj->b->c;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SO5I7
function name:  (null)
number of ops:  9
compiled vars:  !0 = $array, !1 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   18     1        INIT_FCALL                                               'recursivelycreateobjs'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $3      
          4        ASSIGN                                                   !1, $3
   20     5        FETCH_OBJ_R                                      ~5      !1, 'b'
          6        FETCH_OBJ_R                                      ~6      ~5, 'c'
          7        ECHO                                                     ~6
          8      > RETURN                                                   1

Function recursivelycreateobjs:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 18
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 18
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 15
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
filename:       /in/SO5I7
function name:  recursivelyCreateObjs
number of ops:  21
compiled vars:  !0 = $array, !1 = $obj, !2 = $value, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    6     1        NEW                                              $4      'stdClass'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $4
    7     4      > FE_RESET_R                                       $7      !0, ->18
          5    > > FE_FETCH_R                                       ~8      $7, !2, ->18
          6    >   ASSIGN                                                   !3, ~8
    8     7        TYPE_CHECK                                  128          !2
          8      > JMPZ                                                     ~10, ->15
    9     9    >   INIT_FCALL_BY_NAME                                       'recursivelyCreateObjs'
         10        SEND_VAR_EX                                              !2
         11        DO_FCALL                                      0  $12     
         12        ASSIGN_OBJ                                               !1, !3
         13        OP_DATA                                                  $12
         14      > JMP                                                      ->17
   12    15    >   ASSIGN_OBJ                                               !1, !3
         16        OP_DATA                                                  !2
    7    17    > > JMP                                                      ->5
         18    >   FE_FREE                                                  $7
   15    19      > RETURN                                                   !1
   16    20*     > RETURN                                                   null

End of function recursivelycreateobjs

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.51 ms | 1399 KiB | 14 Q