3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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 );
based on eEtQm
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/AEudS
function name:  (null)
number of ops:  41
compiled vars:  !0 = $obj, !1 = $array
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   3     0  E >   NEW                                              $2      :-6
         1        DO_FCALL                                      0          
         2        ASSIGN                                                   !0, $2
   4     3        NEW                                              $6      :-3
         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     :6
        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     :15
        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'
  12    32        NOP                                                      
  28    33        INIT_FCALL                                               'objecttoarray'
        34        SEND_VAL                                                 'array%28%29'
        35        DO_FCALL                                      0  $27     
        36        ASSIGN                                                   !1, $27
  31    37        INIT_FCALL                                               'print_r'
        38        SEND_VAR                                                 !1
        39        DO_ICALL                                                 
        40      > RETURN                                                   1

Function objecttoarray:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = 4, Position 2 = 7
Branch analysis from position: 4
Jump found. Position 1 = 8, Position 2 = 9
Branch analysis from position: 8
Jump found. Position 1 = -2
Branch analysis from position: 9
Jump found. Position 1 = 11, Position 2 = 15
Branch analysis from position: 11
Jump found. 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                                    8  ~1      !0
         2        BOOL_NOT                                         ~2      ~1
         3      > JMPZ_EX                                          ~2      ~2, ->7
         4    >   TYPE_CHECK                                    7  ~3      !0
         5        BOOL_NOT                                         ~4      ~3
         6        BOOL                                             ~2      ~4
         7    > > JMPZ                                                     ~2, ->9
  16     8    > > RETURN                                                   !0
  19     9    >   TYPE_CHECK                                    8  ~5      !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 7.3.0