3v4l.org

run code in 300+ PHP versions simultaneously
<?php $obj = new stdClass; $obj->foo = new stdClass; $obj->foo->baz = 'baz'; $obj->bar = 'bar'; $obj->foo->baz = new stdClass; $obj->foo->baz->test = 'baz test'; $obj->foo->baz->test = new stdClass; $obj->foo->baz->test->conket = 'baz test'; function objectToArray( $object ) { if( !is_object( $object ) && !is_array( $object ) ) { return $object; } if( is_object( $object ) ) { $object = get_object_vars( $object ); } return array_map( __FUNCTION__, $object ); } /*** convert the array to object ***/ $array = objectToArray( 'array()' ); /*** show the array ***/ print_r( $array );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/AEudS
function name:  (null)
number of ops:  40
compiled vars:  !0 = $obj, !1 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   NEW                                              $2      'stdClass'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
    4     3        NEW                                              $6      'stdClass'
          4        DO_FCALL                                      0          
          5        ASSIGN_OBJ                                               !0, 'foo'
          6        OP_DATA                                                  $6
    5     7        FETCH_OBJ_W                                      $8      !0, 'foo'
          8        ASSIGN_OBJ                                               $8, 'baz'
          9        OP_DATA                                                  'baz'
    6    10        ASSIGN_OBJ                                               !0, 'bar'
         11        OP_DATA                                                  'bar'
    7    12        NEW                                              $13     'stdClass'
         13        DO_FCALL                                      0          
         14        FETCH_OBJ_W                                      $11     !0, 'foo'
         15        ASSIGN_OBJ                                               $11, 'baz'
         16        OP_DATA                                                  $13
    8    17        FETCH_OBJ_W                                      $15     !0, 'foo'
         18        FETCH_OBJ_W                                      $16     $15, 'baz'
         19        ASSIGN_OBJ                                               $16, 'test'
         20        OP_DATA                                                  'baz+test'
    9    21        NEW                                              $21     'stdClass'
         22        DO_FCALL                                      0          
         23        FETCH_OBJ_W                                      $18     !0, 'foo'
         24        FETCH_OBJ_W                                      $19     $18, 'baz'
         25        ASSIGN_OBJ                                               $19, 'test'
         26        OP_DATA                                                  $21
   10    27        FETCH_OBJ_W                                      $23     !0, 'foo'
         28        FETCH_OBJ_W                                      $24     $23, 'baz'
         29        FETCH_OBJ_W                                      $25     $24, 'test'
         30        ASSIGN_OBJ                                               $25, 'conket'
         31        OP_DATA                                                  'baz+test'
   28    32        INIT_FCALL                                               'objecttoarray'
         33        SEND_VAL                                                 'array%28%29'
         34        DO_FCALL                                      0  $27     
         35        ASSIGN                                                   !1, $27
   31    36        INIT_FCALL                                               'print_r'
         37        SEND_VAR                                                 !1
         38        DO_ICALL                                                 
         39      > RETURN                                                   1

Function objecttoarray:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 4, Position 2 = 7
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 9
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 15
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
Branch analysis from position: 7
filename:       /in/AEudS
function name:  objectToArray
number of ops:  21
compiled vars:  !0 = $object
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   14     1        TYPE_CHECK                                  256  ~1      !0
          2        BOOL_NOT                                         ~2      ~1
          3      > JMPZ_EX                                          ~2      ~2, ->7
          4    >   TYPE_CHECK                                  128  ~3      !0
          5        BOOL_NOT                                         ~4      ~3
          6        BOOL                                             ~2      ~4
          7    > > JMPZ                                                     ~2, ->9
   16     8    > > RETURN                                                   !0
   19     9    >   TYPE_CHECK                                  256          !0
         10      > JMPZ                                                     ~5, ->15
   21    11    >   INIT_FCALL                                               'get_object_vars'
         12        SEND_VAR                                                 !0
         13        DO_ICALL                                         $6      
         14        ASSIGN                                                   !0, $6
   24    15    >   INIT_FCALL                                               'array_map'
         16        SEND_VAL                                                 'objectToArray'
         17        SEND_VAR                                                 !0
         18        DO_ICALL                                         $8      
         19      > RETURN                                                   $8
   25    20*     > RETURN                                                   null

End of function objecttoarray

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.62 ms | 1403 KiB | 20 Q