3v4l.org

run code in 300+ PHP versions simultaneously
<?php $x = '<?xml version="1.0" encoding="utf-8"?> <SHOP> <SHOPITEM> <name>BLUE product</name> <IMGURL>main_picture.jpg</IMGURL> <PRODUCT_VARIANT id="2"> <name>blue L</name> <IMGURL>blue.jpg</IMGURL> </PRODUCT_VARIANT> <PRODUCT_VARIANT id="3"> <name>BLUE XL</name> <IMGURL>blue.jpg</IMGURL> </PRODUCT_VARIANT> <PRODUCT_VARIANT id="4"> <name>BLUE XXL</name> <IMGURL>blue.jpg</IMGURL> </PRODUCT_VARIANT> </SHOPITEM> </SHOP>'; $dom = new DOMDocument(); $dom->formatOutput = True; libxml_use_internal_errors( 1 ); $dom->loadXML( $x, LIBXML_NOBLANKS ); $xpath = new DOMXPath( $dom ); $nodes = $xpath->query( '//SHOP/SHOPITEM/PRODUCT_VARIANT/IMGURL' ); //q($nodes->length); $found = array(); foreach( $nodes as $key => $node ) { // $node = $nodes->item( $i ); if( in_array( $node->nodeValue, $found ) ) { $node->nodeValue = ''; } else { $found[] = $node->nodeValue; } } echo $dom->saveXML();
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 23, Position 2 = 38
Branch analysis from position: 23
2 jumps found. (Code = 78) Position 1 = 24, Position 2 = 38
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 34
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
Branch analysis from position: 38
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 38
filename:       /in/FCDVI
function name:  (null)
number of ops:  43
compiled vars:  !0 = $x, !1 = $dom, !2 = $xpath, !3 = $nodes, !4 = $found, !5 = $node, !6 = $key
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%3CSHOP%3E%0A++%3CSHOPITEM%3E%0A++++%3Cname%3EBLUE+product%3C%2Fname%3E%0A++++%3CIMGURL%3Emain_picture.jpg%3C%2FIMGURL%3E%0A++++%3CPRODUCT_VARIANT+id%3D%222%22%3E%0A++++++%3Cname%3Eblue+L%3C%2Fname%3E%0A++++++%3CIMGURL%3Eblue.jpg%3C%2FIMGURL%3E%0A++++%3C%2FPRODUCT_VARIANT%3E%0A++++%3CPRODUCT_VARIANT+id%3D%223%22%3E%0A++++++%3Cname%3EBLUE+XL%3C%2Fname%3E%0A++++++%3CIMGURL%3Eblue.jpg%3C%2FIMGURL%3E%0A++++%3C%2FPRODUCT_VARIANT%3E%0A++++%3CPRODUCT_VARIANT+id%3D%224%22%3E%0A++++++%3Cname%3EBLUE+XXL%3C%2Fname%3E%0A++++++%3CIMGURL%3Eblue.jpg%3C%2FIMGURL%3E%0A++++%3C%2FPRODUCT_VARIANT%3E%0A++%3C%2FSHOPITEM%3E%0A%3C%2FSHOP%3E'
   23     1        NEW                                              $8      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $8
   24     4        ASSIGN_OBJ                                               !1, 'formatOutput'
          5        OP_DATA                                                  <true>
   25     6        INIT_FCALL                                               'libxml_use_internal_errors'
          7        SEND_VAL                                                 1
          8        DO_ICALL                                                 
   26     9        INIT_METHOD_CALL                                         !1, 'loadXML'
         10        SEND_VAR_EX                                              !0
         11        SEND_VAL_EX                                              256
         12        DO_FCALL                                      0          
   28    13        NEW                                              $14     'DOMXPath'
         14        SEND_VAR_EX                                              !1
         15        DO_FCALL                                      0          
         16        ASSIGN                                                   !2, $14
   30    17        INIT_METHOD_CALL                                         !2, 'query'
         18        SEND_VAL_EX                                              '%2F%2FSHOP%2FSHOPITEM%2FPRODUCT_VARIANT%2FIMGURL'
         19        DO_FCALL                                      0  $17     
         20        ASSIGN                                                   !3, $17
   32    21        ASSIGN                                                   !4, <array>
   34    22      > FE_RESET_R                                       $20     !3, ->38
         23    > > FE_FETCH_R                                       ~21     $20, !5, ->38
         24    >   ASSIGN                                                   !6, ~21
   37    25        INIT_FCALL                                               'in_array'
         26        FETCH_OBJ_R                                      ~23     !5, 'nodeValue'
         27        SEND_VAL                                                 ~23
         28        SEND_VAR                                                 !4
         29        DO_ICALL                                         $24     
         30      > JMPZ                                                     $24, ->34
   38    31    >   ASSIGN_OBJ                                               !5, 'nodeValue'
         32        OP_DATA                                                  ''
   37    33      > JMP                                                      ->37
   40    34    >   FETCH_OBJ_R                                      ~27     !5, 'nodeValue'
         35        ASSIGN_DIM                                               !4
         36        OP_DATA                                                  ~27
   34    37    > > JMP                                                      ->23
         38    >   FE_FREE                                                  $20
   43    39        INIT_METHOD_CALL                                         !1, 'saveXML'
         40        DO_FCALL                                      0  $28     
         41        ECHO                                                     $28
         42      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.59 ms | 1016 KiB | 15 Q