3v4l.org

run code in 300+ PHP versions simultaneously
<?php $ob = new stdClass(); $ob->value = new stdClass(); $first = array(1); $second = array('1'); $third = new stdClass(); $third->{0} = 1; $fourth = new stdClass(); $fourth->{'0'} = 1; $ob->first = $first; $ob->second = $second; $ob->third = $third; $ob->fourth = $fourth; 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/2ZH99
function name:  (null)
number of ops:  37
compiled vars:  !0 = $ob, !1 = $first, !2 = $second, !3 = $third, !4 = $fourth
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   NEW                                              $5      'stdClass'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $5
    5     3        NEW                                              $9      'stdClass'
          4        DO_FCALL                                      0          
          5        ASSIGN_OBJ                                               !0, 'value'
          6        OP_DATA                                                  $9
    8     7        ASSIGN                                                   !1, <array>
    9     8        ASSIGN                                                   !2, <array>
   11     9        NEW                                              $13     'stdClass'
         10        DO_FCALL                                      0          
         11        ASSIGN                                                   !3, $13
   12    12        ASSIGN_OBJ                                               !3, '0'
         13        OP_DATA                                                  1
   14    14        NEW                                              $17     'stdClass'
         15        DO_FCALL                                      0          
         16        ASSIGN                                                   !4, $17
   15    17        ASSIGN_OBJ                                               !4, '0'
         18        OP_DATA                                                  1
   19    19        ASSIGN_OBJ                                               !0, 'first'
         20        OP_DATA                                                  !1
   20    21        ASSIGN_OBJ                                               !0, 'second'
         22        OP_DATA                                                  !2
   21    23        ASSIGN_OBJ                                               !0, 'third'
         24        OP_DATA                                                  !3
   22    25        ASSIGN_OBJ                                               !0, 'fourth'
         26        OP_DATA                                                  !4
   24    27        INIT_FCALL                                               'print_r'
         28        SEND_VAR                                                 !0
         29        DO_ICALL                                                 
   25    30        INIT_FCALL                                               'print_r'
         31        INIT_FCALL_BY_NAME                                       'object_to_array'
         32        SEND_VAR_EX                                              !0
         33        DO_FCALL                                      0  $26     
         34        SEND_VAR                                                 $26
         35        DO_ICALL                                                 
   39    36      > 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/2ZH99
function name:  object_to_array
number of ops:  21
compiled vars:  !0 = $object
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   RECV                                             !0      
   32     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
   33     8    > > RETURN                                                   !0
   35     9    >   TYPE_CHECK                                  256          !0
         10      > JMPZ                                                     ~5, ->15
   36    11    >   INIT_FCALL                                               'get_object_vars'
         12        SEND_VAR                                                 !0
         13        DO_ICALL                                         $6      
         14        ASSIGN                                                   !0, $6
   38    15    >   INIT_FCALL                                               'array_map'
         16        SEND_VAL                                                 'object_to_array'
         17        SEND_VAR                                                 !0
         18        DO_ICALL                                         $8      
         19      > RETURN                                                   $8
   39    20*     > RETURN                                                   null

End of function object_to_array

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.9 ms | 1400 KiB | 19 Q