3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xml = '<products> <product> <categoryName>Kable i konwertery AV</categoryName> <brandName>Belkin</brandName> <productCode>AV10176bt1M-BLK</productCode> <productId>5616488</productId> <productFullName>Kabel Belkin Kabel HDMI Ultra HD High Speed 1m-AV10176bt1M-BLK</productFullName> <productEan>0745883767465</productEan> <productEuroPriceNetto>59.71</productEuroPriceNetto> <productFrontendPriceNetto>258.54</productFrontendPriceNetto> <productFastestSupplierQuantity>23</productFastestSupplierQuantity> <deliveryEstimatedDays>2</deliveryEstimatedDays> </product> <product> <categoryName>Telewizory</categoryName> <brandName>Sony</brandName> <productCode>KDL32WD757SAEP</productCode> <productId>1005662</productId> <productFullName>Telewizor Sony KDL-32WD757 SAEP</productFullName> <productEan></productEan> <productEuroPriceNetto>412.33</productEuroPriceNetto> <productFrontendPriceNetto>1785.38</productFrontendPriceNetto> <productFastestSupplierQuantity>11</productFastestSupplierQuantity> <deliveryEstimatedDays>6</deliveryEstimatedDays> </product> <product> <categoryName>Kuchnie i akcesoria</categoryName> <brandName>Brimarex</brandName> <productCode>1566287</productCode> <productId>885156</productId> <productFullName>Brimarex Drewniane owoce, Kiwi - 1566287</productFullName> <productEan></productEan> <productEuroPriceNetto>0.7</productEuroPriceNetto> <productFrontendPriceNetto>3.05</productFrontendPriceNetto> <productFastestSupplierQuantity>7</productFastestSupplierQuantity> <deliveryEstimatedDays>3</deliveryEstimatedDays> </product> </products>'; $reader = new XMLReader(); $reader->xml($xml); $count = 0; $this_value = ''; $products = array(); while($reader->read()) { switch ($reader->nodeType) { case XMLReader::ELEMENT: // deal with self-closing tags e.g. <productEan /> if ($reader->isEmptyElement) { ${$reader->name} = ''; $products[$count][$reader->name] = ''; } break; case XMLReader::TEXT: case XMLReader::CDATA: // save the value for storage when we get to the end of the element $this_value = $reader->value; break; case XMLReader::END_ELEMENT: if ($reader->name == 'product') { $count++; print_r(array($categoryName, $brandName, $productCode, $productId, $productFullName, $productEan, $productEuroPriceNetto, $productFrontendPriceNetto, $productFastestSupplierQuantity, $deliveryEstimatedDays)); } elseif ($reader->name != 'products') { ${$reader->name} = $this_value; $products[$count][$reader->name] = $this_value; // set this_value to a blank string to allow for empty tags $this_value = ''; } break; case XMLReader::WHITESPACE: case XMLReader::SIGNIFICANT_WHITESPACE: default: // nothing to do break; } } $reader->close(); print_r($products);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 71
Branch analysis from position: 71
2 jumps found. (Code = 44) Position 1 = 74, Position 2 = 11
Branch analysis from position: 74
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
8 jumps found. (Code = 187) Position 1 = 26, Position 2 = 36, Position 3 = 36, Position 4 = 39, Position 5 = 69, Position 6 = 69, Position 7 = 69, Position 8 = 13
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 35
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 70
Branch analysis from position: 70
2 jumps found. (Code = 44) Position 1 = 74, Position 2 = 11
Branch analysis from position: 74
Branch analysis from position: 11
Branch analysis from position: 35
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 70
Branch analysis from position: 70
Branch analysis from position: 36
Branch analysis from position: 39
2 jumps found. (Code = 43) Position 1 = 42, Position 2 = 57
Branch analysis from position: 42
1 jumps found. (Code = 42) Position 1 = 68
Branch analysis from position: 68
1 jumps found. (Code = 42) Position 1 = 70
Branch analysis from position: 70
Branch analysis from position: 57
2 jumps found. (Code = 43) Position 1 = 60, Position 2 = 68
Branch analysis from position: 60
1 jumps found. (Code = 42) Position 1 = 70
Branch analysis from position: 70
Branch analysis from position: 68
Branch analysis from position: 69
1 jumps found. (Code = 42) Position 1 = 70
Branch analysis from position: 70
Branch analysis from position: 69
Branch analysis from position: 69
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 15, Position 2 = 26
Branch analysis from position: 15
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 36
Branch analysis from position: 17
2 jumps found. (Code = 44) Position 1 = 19, Position 2 = 36
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 21, Position 2 = 39
Branch analysis from position: 21
2 jumps found. (Code = 44) Position 1 = 23, Position 2 = 69
Branch analysis from position: 23
2 jumps found. (Code = 44) Position 1 = 25, Position 2 = 69
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 69
Branch analysis from position: 69
Branch analysis from position: 69
Branch analysis from position: 69
Branch analysis from position: 39
Branch analysis from position: 36
Branch analysis from position: 36
Branch analysis from position: 26
filename:       /in/BIjM2
function name:  (null)
number of ops:  80
compiled vars:  !0 = $xml, !1 = $reader, !2 = $count, !3 = $this_value, !4 = $products, !5 = $categoryName, !6 = $brandName, !7 = $productCode, !8 = $productId, !9 = $productFullName, !10 = $productEan, !11 = $productEuroPriceNetto, !12 = $productFrontendPriceNetto, !13 = $productFastestSupplierQuantity, !14 = $deliveryEstimatedDays
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%3Cproducts%3E%0A%3Cproduct%3E%0A%3CcategoryName%3EKable+i+konwertery+AV%3C%2FcategoryName%3E%0A%3CbrandName%3EBelkin%3C%2FbrandName%3E%0A%3CproductCode%3EAV10176bt1M-BLK%3C%2FproductCode%3E%0A%3CproductId%3E5616488%3C%2FproductId%3E%0A%3CproductFullName%3EKabel+Belkin+Kabel+HDMI+Ultra+HD+High+Speed+1m-AV10176bt1M-BLK%3C%2FproductFullName%3E%0A%3CproductEan%3E0745883767465%3C%2FproductEan%3E%0A%3CproductEuroPriceNetto%3E59.71%3C%2FproductEuroPriceNetto%3E%0A%3CproductFrontendPriceNetto%3E258.54%3C%2FproductFrontendPriceNetto%3E%0A%3CproductFastestSupplierQuantity%3E23%3C%2FproductFastestSupplierQuantity%3E%0A%3CdeliveryEstimatedDays%3E2%3C%2FdeliveryEstimatedDays%3E%0A%3C%2Fproduct%3E%0A%3Cproduct%3E%0A%3CcategoryName%3ETelewizory%3C%2FcategoryName%3E%0A%3CbrandName%3ESony%3C%2FbrandName%3E%0A%3CproductCode%3EKDL32WD757SAEP%3C%2FproductCode%3E%0A%3CproductId%3E1005662%3C%2FproductId%3E%0A%3CproductFullName%3ETelewizor+Sony+KDL-32WD757+SAEP%3C%2FproductFullName%3E%0A%3CproductEan%3E%3C%2FproductEan%3E%0A%3CproductEuroPriceNetto%3E412.33%3C%2FproductEuroPriceNetto%3E%0A%3CproductFrontendPriceNetto%3E1785.38%3C%2FproductFrontendPriceNetto%3E%0A%3CproductFastestSupplierQuantity%3E11%3C%2FproductFastestSupplierQuantity%3E%0A%3CdeliveryEstimatedDays%3E6%3C%2FdeliveryEstimatedDays%3E%0A%3C%2Fproduct%3E%0A%3Cproduct%3E%0A%3CcategoryName%3EKuchnie+i+akcesoria%3C%2FcategoryName%3E%0A%3CbrandName%3EBrimarex%3C%2FbrandName%3E%0A%3CproductCode%3E1566287%3C%2FproductCode%3E%0A%3CproductId%3E885156%3C%2FproductId%3E%0A%3CproductFullName%3EBrimarex+Drewniane+owoce%2C+Kiwi+-+1566287%3C%2FproductFullName%3E%0A%3CproductEan%3E%3C%2FproductEan%3E%0A%3CproductEuroPriceNetto%3E0.7%3C%2FproductEuroPriceNetto%3E%0A%3CproductFrontendPriceNetto%3E3.05%3C%2FproductFrontendPriceNetto%3E%0A%3CproductFastestSupplierQuantity%3E7%3C%2FproductFastestSupplierQuantity%3E%0A%3CdeliveryEstimatedDays%3E3%3C%2FdeliveryEstimatedDays%3E%0A%3C%2Fproduct%3E%0A%3C%2Fproducts%3E'
   40     1        NEW                                              $16     'XMLReader'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $16
   41     4        INIT_METHOD_CALL                                         !1, 'xml'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
   42     7        ASSIGN                                                   !2, 0
   43     8        ASSIGN                                                   !3, ''
   44     9        ASSIGN                                                   !4, <array>
   45    10      > JMP                                                      ->71
   46    11    >   FETCH_OBJ_R                                      ~23     !1, 'nodeType'
         12      > SWITCH_LONG                                              ~23, [ 1:->26, 3:->36, 4:->36, 15:->39, 13:->69, 14:->69, ], ->69
         13    >   CASE                                                     ~23, 1
         14      > JMPNZ                                                    ~24, ->26
         15    >   CASE                                                     ~23, 3
         16      > JMPNZ                                                    ~24, ->36
         17    >   CASE                                                     ~23, 4
         18      > JMPNZ                                                    ~24, ->36
         19    >   CASE                                                     ~23, 15
         20      > JMPNZ                                                    ~24, ->39
         21    >   CASE                                                     ~23, 13
         22      > JMPNZ                                                    ~24, ->69
         23    >   CASE                                                     ~23, 14
         24      > JMPNZ                                                    ~24, ->69
         25    > > JMP                                                      ->69
   49    26    >   FETCH_OBJ_R                                      ~25     !1, 'isEmptyElement'
         27      > JMPZ                                                     ~25, ->35
   50    28    >   FETCH_OBJ_R                                      ~26     !1, 'name'
         29        FETCH_W                      local               $27     ~26
         30        ASSIGN                                                   $27, ''
   51    31        FETCH_OBJ_R                                      ~30     !1, 'name'
         32        FETCH_DIM_W                                      $29     !4, !2
         33        ASSIGN_DIM                                               $29, ~30
         34        OP_DATA                                                  ''
   53    35    > > JMP                                                      ->70
   57    36    >   FETCH_OBJ_R                                      ~32     !1, 'value'
         37        ASSIGN                                                   !3, ~32
   58    38      > JMP                                                      ->70
   60    39    >   FETCH_OBJ_R                                      ~34     !1, 'name'
         40        IS_EQUAL                                                 ~34, 'product'
         41      > JMPZ                                                     ~35, ->57
   61    42    >   PRE_INC                                                  !2
   62    43        INIT_FCALL                                               'print_r'
         44        INIT_ARRAY                                       ~37     !5
         45        ADD_ARRAY_ELEMENT                                ~37     !6
         46        ADD_ARRAY_ELEMENT                                ~37     !7
         47        ADD_ARRAY_ELEMENT                                ~37     !8
         48        ADD_ARRAY_ELEMENT                                ~37     !9
         49        ADD_ARRAY_ELEMENT                                ~37     !10
         50        ADD_ARRAY_ELEMENT                                ~37     !11
         51        ADD_ARRAY_ELEMENT                                ~37     !12
         52        ADD_ARRAY_ELEMENT                                ~37     !13
         53        ADD_ARRAY_ELEMENT                                ~37     !14
         54        SEND_VAL                                                 ~37
         55        DO_ICALL                                                 
   60    56      > JMP                                                      ->68
   64    57    >   FETCH_OBJ_R                                      ~39     !1, 'name'
         58        IS_NOT_EQUAL                                             ~39, 'products'
         59      > JMPZ                                                     ~40, ->68
   65    60    >   FETCH_OBJ_R                                      ~41     !1, 'name'
         61        FETCH_W                      local               $42     ~41
         62        ASSIGN                                                   $42, !3
   66    63        FETCH_OBJ_R                                      ~45     !1, 'name'
         64        FETCH_DIM_W                                      $44     !4, !2
         65        ASSIGN_DIM                                               $44, ~45
         66        OP_DATA                                                  !3
   68    67        ASSIGN                                                   !3, ''
   70    68    > > JMP                                                      ->70
   75    69    > > JMP                                                      ->70
         70    >   FREE                                                     ~23
   45    71    >   INIT_METHOD_CALL                                         !1, 'read'
         72        DO_FCALL                                      0  $48     
         73      > JMPNZ                                                    $48, ->11
   78    74    >   INIT_METHOD_CALL                                         !1, 'close'
         75        DO_FCALL                                      0          
   79    76        INIT_FCALL                                               'print_r'
         77        SEND_VAR                                                 !4
         78        DO_ICALL                                                 
         79      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
233.38 ms | 1007 KiB | 14 Q