3v4l.org

run code in 300+ PHP versions simultaneously
<?php $s = '<?xml version="1.0" encoding="utf-8" standalone="yes" ?>'. '<request><body test2="321" test3="987">'. '<rows><my-row test4="564">'. '<types>'. '<custom>this is the example of the text</custom>'. '<Generic arch="simple">this is the example of the text</Generic>'. '<bold/><italic/><underlined/>'. '</types>'. '</my-row><my-row test5="565"/><test hidden="false" ready="true"/></rows>'. '</body></request>'; $xml = simplexml_load_string($s); foreach($xml->children() as $state) { $states[]= array('state' => (string)$state->name); } echo json_encode($states); /*function f($xml, $stack = null) { print_r(array( 'call', $stack )); $stack = count($stack) ? $stack : array(); foreach ($xml as $key => $value) { $stack[$key] = null; if (count($value->attributes())) $stack[$key]['attributes'] = (array)$value->attributes(); if (is_string($value)) $stack[$key]['content'] = (string)$value; /*print_r(array( 'key' => $key, 'hasChildren' => (bool)$xml->hasChildren(), 'attributes' => (array)$value->attributes(), 'stack' => $s, ));* print_r(array( 'call', $value, )); if (get_class($value) == 'SimpleXMLIterator' && $xml->hasChildren()) f($xml->getChildren(), $stack); } return $stack; } print_r(f(new SimpleXMLIterator($s)));*/
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 15
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 15
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/Yr1M5
function name:  (null)
number of ops:  21
compiled vars:  !0 = $s, !1 = $xml, !2 = $state, !3 = $states
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%3C%3Fxml+version%3D%221.0%22+encoding%3D%22utf-8%22+standalone%3D%22yes%22+%3F%3E%3Crequest%3E%3Cbody+test2%3D%22321%22+test3%3D%22987%22%3E%3Crows%3E%3Cmy-row+test4%3D%22564%22%3E%3Ctypes%3E%3Ccustom%3Ethis+is+the+example+of+the+text%3C%2Fcustom%3E%3CGeneric+arch%3D%22simple%22%3Ethis+is+the+example+of+the+text%3C%2FGeneric%3E%3Cbold%2F%3E%3Citalic%2F%3E%3Cunderlined%2F%3E%3C%2Ftypes%3E%3C%2Fmy-row%3E%3Cmy-row+test5%3D%22565%22%2F%3E%3Ctest+hidden%3D%22false%22+ready%3D%22true%22%2F%3E%3C%2Frows%3E%3C%2Fbody%3E%3C%2Frequest%3E'
   13     1        INIT_FCALL                                               'simplexml_load_string'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $5      
          4        ASSIGN                                                   !1, $5
   15     5        INIT_METHOD_CALL                                         !1, 'children'
          6        DO_FCALL                                      0  $7      
          7      > FE_RESET_R                                       $8      $7, ->15
          8    > > FE_FETCH_R                                               $8, !2, ->15
   17     9    >   FETCH_OBJ_R                                      ~10     !2, 'name'
         10        CAST                                          6  ~11     ~10
         11        INIT_ARRAY                                       ~12     ~11, 'state'
         12        ASSIGN_DIM                                               !3
         13        OP_DATA                                                  ~12
   15    14      > JMP                                                      ->8
         15    >   FE_FREE                                                  $8
   19    16        INIT_FCALL                                               'json_encode'
         17        SEND_VAR                                                 !3
         18        DO_ICALL                                         $13     
         19        ECHO                                                     $13
   50    20      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.51 ms | 1395 KiB | 17 Q