3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xml=simplexml_load_string(<<<XML <?xml version="1.0"?> <root> <Services> <Service> <ServiceCode>Route ID</ServiceCode> <RegisteredOperatorRef>Agency ID</RegisteredOperatorRef> <LineName>Route Short Name</LineName> <Description>Route Description</Description> <Mode>Route Type</Mode> </Service> </Services> </root> XML ); $api=array ( 'route_id' => array('Services', 'Service', 'ServiceCode'), 'agency_id' => array('Services', 'Service', 'RegisteredOperatorRef'), 'route_short_name' => array('Services', 'Service', 'LineName'), 'route_desc' => array('Services', 'Service', 'Description'), 'route_type' => array('Services', 'Service', 'Mode') ); function findText($entry,array $api,SimpleXMLElement $xml) { if(!empty($api[$entry])) { $cache=$xml; foreach($api[$entry] as $node) { $cache=$cache->{$node}; } return (String)$cache; } else { return null; } } echo findText("route_id",$api,$xml);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/WrZNF
function name:  (null)
number of ops:  12
compiled vars:  !0 = $xml, !1 = $api
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL                                               'simplexml_load_string'
    3     1        SEND_VAL                                                 '%3C%3Fxml+version%3D%221.0%22%3F%3E%0A%3Croot%3E%0A%09%3CServices%3E%0A%09%09%3CService%3E%0A%09%09%09%3CServiceCode%3ERoute+ID%3C%2FServiceCode%3E%0A%09%09%09%3CRegisteredOperatorRef%3EAgency+ID%3C%2FRegisteredOperatorRef%3E%0A%09%09%09%3CLineName%3ERoute+Short+Name%3C%2FLineName%3E%0A%09%09%09%3CDescription%3ERoute+Description%3C%2FDescription%3E%0A%09%09%09%3CMode%3ERoute+Type%3C%2FMode%3E%0A%09%09%3C%2FService%3E%0A%09%3C%2FServices%3E%0A%3C%2Froot%3E'
    2     2        DO_ICALL                                         $2      
          3        ASSIGN                                                   !0, $2
   17     4        ASSIGN                                                   !1, <array>
   40     5        INIT_FCALL                                               'findtext'
          6        SEND_VAL                                                 'route_id'
          7        SEND_VAR                                                 !1
          8        SEND_VAR                                                 !0
          9        DO_FCALL                                      0  $5      
         10        ECHO                                                     $5
         11      > RETURN                                                   1

Function findtext:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 17
Branch analysis from position: 6
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 13
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 13
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/WrZNF
function name:  findText
number of ops:  19
compiled vars:  !0 = $entry, !1 = $api, !2 = $xml, !3 = $cache, !4 = $node
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   26     3        ISSET_ISEMPTY_DIM_OBJ                         1  ~5      !1, !0
          4        BOOL_NOT                                         ~6      ~5
          5      > JMPZ                                                     ~6, ->17
   28     6    >   ASSIGN                                                   !3, !2
   29     7        FETCH_DIM_R                                      ~8      !1, !0
          8      > FE_RESET_R                                       $9      ~8, ->13
          9    > > FE_FETCH_R                                               $9, !4, ->13
   31    10    >   FETCH_OBJ_R                                      ~10     !3, !4
         11        ASSIGN                                                   !3, ~10
   29    12      > JMP                                                      ->9
         13    >   FE_FREE                                                  $9
   33    14        CAST                                          6  ~12     !3
         15      > RETURN                                                   ~12
   26    16*       JMP                                                      ->18
   37    17    > > RETURN                                                   null
   39    18*     > RETURN                                                   null

End of function findtext

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
137.89 ms | 1005 KiB | 15 Q