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/7GKhr
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
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7GKhr
function name:  objectToArray
number of ops:  6
compiled vars:  !0 = $input, !1 = $arrayObject
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        NEW                                              $2      'ArrayObject'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !1, $2
   12     5      > RETURN                                                   null

End of function objecttoarray

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
176.27 ms | 1397 KiB | 16 Q