3v4l.org

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

End of function object_to_array

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.24 ms | 1392 KiB | 19 Q