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/eEtQm
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 = 43) Position 1 = 3, Position 2 = 7
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
filename:       /in/eEtQm
function name:  objectToArray
number of ops:  13
compiled vars:  !0 = $object
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   19     1        TYPE_CHECK                                  256          !0
          2      > JMPZ                                                     ~1, ->7
   21     3    >   INIT_FCALL                                               'get_object_vars'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $2      
          6        ASSIGN                                                   !0, $2
   24     7    >   INIT_FCALL                                               'array_map'
          8        SEND_VAL                                                 'objectToArray'
          9        SEND_VAR                                                 !0
         10        DO_ICALL                                         $4      
         11      > RETURN                                                   $4
   25    12*     > RETURN                                                   null

End of function objecttoarray

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.67 ms | 1403 KiB | 20 Q