3v4l.org

run code in 300+ PHP versions simultaneously
<?php function objectToArray($input) { $arrayObject = new ArrayObject($input); //die(print_r($arrayObject)); foreach($arrayObject as $key => $val) { //if (!is_object($val)) { // continue; //} //$arrayObject[$key] = objectToArray($val); } //return $arrayObject; } $object = json_decode('{"menu":{"id":"file","value":"File","popup":{"menuitem":[{"value":"New","onclick":"CreateNewDoc()"},{"value":"Open","onclick":"OpenDoc()"},{"value":"Close","onclick":"CloseDoc()"}]}}}'); $array = objectToArray($object);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eCCCl
function name:  (null)
number of ops:  9
compiled vars:  !0 = $object, !1 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   INIT_FCALL                                               'json_decode'
          1        SEND_VAL                                                 '%7B%22menu%22%3A%7B%22id%22%3A%22file%22%2C%22value%22%3A%22File%22%2C%22popup%22%3A%7B%22menuitem%22%3A%5B%7B%22value%22%3A%22New%22%2C%22onclick%22%3A%22CreateNewDoc%28%29%22%7D%2C%7B%22value%22%3A%22Open%22%2C%22onclick%22%3A%22OpenDoc%28%29%22%7D%2C%7B%22value%22%3A%22Close%22%2C%22onclick%22%3A%22CloseDoc%28%29%22%7D%5D%7D%7D%7D'
          2        DO_ICALL                                         $2      
          3        ASSIGN                                                   !0, $2
   16     4        INIT_FCALL                                               'objecttoarray'
          5        SEND_VAR                                                 !0
          6        DO_FCALL                                      0  $4      
          7        ASSIGN                                                   !1, $4
          8      > RETURN                                                   1

Function objecttoarray:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 9
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
filename:       /in/eCCCl
function name:  objectToArray
number of ops:  11
compiled vars:  !0 = $input, !1 = $arrayObject, !2 = $val, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        NEW                                              $4      'ArrayObject'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !1, $4
    5     5      > FE_RESET_R                                       $7      !1, ->9
          6    > > FE_FETCH_R                                       ~8      $7, !2, ->9
          7    >   ASSIGN                                                   !3, ~8
          8      > JMP                                                      ->6
          9    >   FE_FREE                                                  $7
   12    10      > RETURN                                                   null

End of function objecttoarray

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
173.37 ms | 1399 KiB | 16 Q