3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xml = <<<DATA <?xml version="1.0" encoding="UTF-8"?> <ns1:catalog xmlns:ns1="http://www.omnichannelintegrationlayer.com/xml/catalog/2016-01-01" catalog-id="at-master-catalog"> <ns1:product product-id="4132002004"> <ns1:min-order-quantity>1</ns1:min-order-quantity> <ns1:step-quantity>1</ns1:step-quantity> <ns1:short-description xmlns:ns2="xml" ns2:lang="de-AT">Jogginghose Cacy jr </ns1:short-description> <ns1:short-description xmlns:ns2="xml" ns2:lang="de-CH">Jogginghose Cacy jr </ns1:short-description> </ns1:product> </ns1:catalog> DATA; $xml = simplexml_load_string($xml); $productid = "4132002004"; $namespaces = $xml->getNamespaces(true); foreach ($xml->xpath("//ns1:product[@product-id='".$productid."']/ns1:short-description") as $short_description) { $langAsString = (string)$short_description->attributes($namespaces['ns2'])->lang; echo $langAsString . PHP_EOL; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 16, Position 2 = 28
Branch analysis from position: 16
2 jumps found. (Code = 78) Position 1 = 17, Position 2 = 28
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
filename:       /in/DbTus
function name:  (null)
number of ops:  30
compiled vars:  !0 = $xml, !1 = $productid, !2 = $namespaces, !3 = $short_description, !4 = $langAsString
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3C%3Fxml+version%3D%221.0%22+encoding%3D%22UTF-8%22%3F%3E%0A%3Cns1%3Acatalog%0A++++++++xmlns%3Ans1%3D%22http%3A%2F%2Fwww.omnichannelintegrationlayer.com%2Fxml%2Fcatalog%2F2016-01-01%22+catalog-id%3D%22at-master-catalog%22%3E%0A++++%3Cns1%3Aproduct+product-id%3D%224132002004%22%3E%0A++++++++%3Cns1%3Amin-order-quantity%3E1%3C%2Fns1%3Amin-order-quantity%3E%0A++++++++%3Cns1%3Astep-quantity%3E1%3C%2Fns1%3Astep-quantity%3E%0A++++++++%3Cns1%3Ashort-description%0A++++++++++++++++xmlns%3Ans2%3D%22xml%22+ns2%3Alang%3D%22de-AT%22%3EJogginghose+Cacy+jr%0A++++++++%3C%2Fns1%3Ashort-description%3E%0A++++++++%3Cns1%3Ashort-description%0A++++++++++++++++xmlns%3Ans2%3D%22xml%22+ns2%3Alang%3D%22de-CH%22%3EJogginghose+Cacy+jr%0A++++++++%3C%2Fns1%3Ashort-description%3E%0A++++%3C%2Fns1%3Aproduct%3E%0A%3C%2Fns1%3Acatalog%3E'
   19     1        INIT_FCALL                                               'simplexml_load_string'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $6      
          4        ASSIGN                                                   !0, $6
   20     5        ASSIGN                                                   !1, '4132002004'
   21     6        INIT_METHOD_CALL                                         !0, 'getNamespaces'
          7        SEND_VAL_EX                                              <true>
          8        DO_FCALL                                      0  $9      
          9        ASSIGN                                                   !2, $9
   22    10        INIT_METHOD_CALL                                         !0, 'xpath'
         11        CONCAT                                           ~11     '%2F%2Fns1%3Aproduct%5B%40product-id%3D%27', !1
         12        CONCAT                                           ~12     ~11, '%27%5D%2Fns1%3Ashort-description'
         13        SEND_VAL_EX                                              ~12
         14        DO_FCALL                                      0  $13     
         15      > FE_RESET_R                                       $14     $13, ->28
         16    > > FE_FETCH_R                                               $14, !3, ->28
   23    17    >   INIT_METHOD_CALL                                         !3, 'attributes'
         18        CHECK_FUNC_ARG                                           
         19        FETCH_DIM_FUNC_ARG                               $15     !2, 'ns2'
         20        SEND_FUNC_ARG                                            $15
         21        DO_FCALL                                      0  $16     
         22        FETCH_OBJ_R                                      ~17     $16, 'lang'
         23        CAST                                          6  ~18     ~17
         24        ASSIGN                                                   !4, ~18
   24    25        CONCAT                                           ~20     !4, '%0A'
         26        ECHO                                                     ~20
   22    27      > JMP                                                      ->16
         28    >   FE_FREE                                                  $14
   25    29      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.65 ms | 1441 KiB | 14 Q