3v4l.org

run code in 300+ PHP versions simultaneously
<?php $ob = new stdClass(); $ob->value = new stdClass(); $array = array('1'); $obi = new stcClass(); $obi->{0} = 1; $ob->value = (object)$array; $ob->val = $obi; print_r($ob); print_r(object_to_array($ob)); function object_to_array( $object ) { if( ! is_array( $object ) && ! is_object( $object )) { return $object; } if( is_object( $object )) { $object = get_object_vars( $object ); } return array_map( 'object_to_array', $object ); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nID9Q
function name:  (null)
number of ops:  28
compiled vars:  !0 = $ob, !1 = $array, !2 = $obi
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   NEW                                              $3      'stdClass'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
    5     3        NEW                                              $7      'stdClass'
          4        DO_FCALL                                      0          
          5        ASSIGN_OBJ                                               !0, 'value'
          6        OP_DATA                                                  $7
    8     7        ASSIGN                                                   !1, <array>
    9     8        NEW                                              $10     'stcClass'
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !2, $10
   10    11        ASSIGN_OBJ                                               !2, '0'
         12        OP_DATA                                                  1
   12    13        CAST                                          8  ~15     !1
         14        ASSIGN_OBJ                                               !0, 'value'
         15        OP_DATA                                                  ~15
   13    16        ASSIGN_OBJ                                               !0, 'val'
         17        OP_DATA                                                  !2
   15    18        INIT_FCALL                                               'print_r'
         19        SEND_VAR                                                 !0
         20        DO_ICALL                                                 
   16    21        INIT_FCALL                                               'print_r'
         22        INIT_FCALL_BY_NAME                                       'object_to_array'
         23        SEND_VAR_EX                                              !0
         24        DO_FCALL                                      0  $18     
         25        SEND_VAR                                                 $18
         26        DO_ICALL                                                 
   30    27      > RETURN                                                   1

Function object_to_array:
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/nID9Q
function name:  object_to_array
number of ops:  21
compiled vars:  !0 = $object
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   RECV                                             !0      
   23     1        TYPE_CHECK                                  128  ~1      !0
          2        BOOL_NOT                                         ~2      ~1
          3      > JMPZ_EX                                          ~2      ~2, ->7
          4    >   TYPE_CHECK                                  256  ~3      !0
          5        BOOL_NOT                                         ~4      ~3
          6        BOOL                                             ~2      ~4
          7    > > JMPZ                                                     ~2, ->9
   24     8    > > RETURN                                                   !0
   26     9    >   TYPE_CHECK                                  256          !0
         10      > JMPZ                                                     ~5, ->15
   27    11    >   INIT_FCALL                                               'get_object_vars'
         12        SEND_VAR                                                 !0
         13        DO_ICALL                                         $6      
         14        ASSIGN                                                   !0, $6
   29    15    >   INIT_FCALL                                               'array_map'
         16        SEND_VAL                                                 'object_to_array'
         17        SEND_VAR                                                 !0
         18        DO_ICALL                                         $8      
         19      > RETURN                                                   $8
   30    20*     > RETURN                                                   null

End of function object_to_array

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.16 ms | 1400 KiB | 19 Q