3v4l.org

run code in 500+ PHP versions simultaneously
<?php $str = '<?xml version="1.0" encoding="utf-8"?> <products> <item> <ItemID>01</ItemID> <ItemName>Book</ItemName> </item> <Product> <ProductID>01</ProductID> <ProductName>Paper</ProductName> </Product>'; $lines = explode("\n", $str); $output = ""; $arrayLength = count($lines); for ($i = 0; $i < $arrayLength; $i++) { $trimmedNextLine = isset($lines[$i + 1]) ? trim($lines[$i + 1]) : null; $line = $lines[$i]; if ($trimmedNextLine == "<Product>") { $output .= $line . $trimmedNextLine; $i++; } else { $output .= $line; } if ($i < $arrayLength) { $output .= "\n"; } } echo $output;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
2 jumps found. (Code = 44) Position 1 = 36, Position 2 = 11
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 19
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 29
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 33
Branch analysis from position: 32
2 jumps found. (Code = 44) Position 1 = 36, Position 2 = 11
Branch analysis from position: 36
Branch analysis from position: 11
Branch analysis from position: 33
Branch analysis from position: 29
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 33
Branch analysis from position: 32
Branch analysis from position: 33
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 29
Branch analysis from position: 25
Branch analysis from position: 29
filename:       /in/pQSED
function name:  (null)
number of ops:  38
compiled vars:  !0 = $str, !1 = $lines, !2 = $output, !3 = $arrayLength, !4 = $i, !5 = $trimmedNextLine, !6 = $line
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%3F%3E%0A%3Cproducts%3E%0A++%3Citem%3E%0A++++%3CItemID%3E01%3C%2FItemID%3E%0A++++%3CItemName%3EBook%3C%2FItemName%3E%0A++%3C%2Fitem%3E%0A++%3CProduct%3E%0A++++%3CProductID%3E01%3C%2FProductID%3E%0A++++%3CProductName%3EPaper%3C%2FProductName%3E%0A++%3C%2FProduct%3E'
   13     1        INIT_FCALL                                                   'explode'
          2        SEND_VAL                                                     '%0A'
          3        SEND_VAR                                                     !0
          4        DO_ICALL                                             $8      
          5        ASSIGN                                                       !1, $8
   15     6        ASSIGN                                                       !2, ''
   17     7        COUNT                                                ~11     !1
          8        ASSIGN                                                       !3, ~11
   19     9        ASSIGN                                                       !4, 0
         10      > JMP                                                          ->34
   20    11    >   ADD                                                  ~14     !4, 1
         12        ISSET_ISEMPTY_DIM_OBJ                             0          !1, ~14
         13      > JMPZ                                                         ~15, ->19
         14    >   ADD                                                  ~16     !4, 1
         15        FETCH_DIM_R                                          ~17     !1, ~16
         16        FRAMELESS_ICALL_1                trim                ~18     ~17
         17        QM_ASSIGN                                            ~19     ~18
         18      > JMP                                                          ->20
         19    >   QM_ASSIGN                                            ~19     null
         20    >   ASSIGN                                                       !5, ~19
   21    21        FETCH_DIM_R                                          ~21     !1, !4
         22        ASSIGN                                                       !6, ~21
   23    23        IS_EQUAL                                                     !5, '%3CProduct%3E'
         24      > JMPZ                                                         ~23, ->29
   24    25    >   CONCAT                                               ~24     !6, !5
         26        ASSIGN_OP                                         8          !2, ~24
   25    27        PRE_INC                                                      !4
   23    28      > JMP                                                          ->30
   27    29    >   ASSIGN_OP                                         8          !2, !6
   30    30    >   IS_SMALLER                                                   !4, !3
         31      > JMPZ                                                         ~28, ->33
   31    32    >   ASSIGN_OP                                         8          !2, '%0A'
   19    33    >   PRE_INC                                                      !4
         34    >   IS_SMALLER                                                   !4, !3
         35      > JMPNZ                                                        ~31, ->11
   35    36    >   ECHO                                                         !2
   36    37      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
158.51 ms | 1923 KiB | 14 Q