3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = "This is a test"; $search = "is"; $pos = 0; $loop = true; while($loop) { # Check if the word can be found in the text $pos = stripos($html,$search,$pos); if($pos !== false) { $spanStart = "<span style='background-color:khaki;'>"; $spanEnd = "</span>"; $html = substr($html,0,$pos) . $spanStart . substr($html,$pos,strlen($search)) . $spanEnd . substr($html,$pos+strlen($search),strlen($html)); $pos = $pos + strlen($search) + strlen($spanStart) + strlen($spanEnd); } else { $loop = false; } } echo "html=[$html]";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 48
Branch analysis from position: 48
2 jumps found. (Code = 44) Position 1 = 49, Position 2 = 5
Branch analysis from position: 49
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 47
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 48
Branch analysis from position: 48
Branch analysis from position: 47
2 jumps found. (Code = 44) Position 1 = 49, Position 2 = 5
Branch analysis from position: 49
Branch analysis from position: 5
filename:       /in/qa8er
function name:  (null)
number of ops:  54
compiled vars:  !0 = $html, !1 = $search, !2 = $pos, !3 = $loop, !4 = $spanStart, !5 = $spanEnd
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'This+is+a+test'
    4     1        ASSIGN                                                   !1, 'is'
    6     2        ASSIGN                                                   !2, 0
    7     3        ASSIGN                                                   !3, <true>
    8     4      > JMP                                                      ->48
   11     5    >   INIT_FCALL                                               'stripos'
          6        SEND_VAR                                                 !0
          7        SEND_VAR                                                 !1
          8        SEND_VAR                                                 !2
          9        DO_ICALL                                         $10     
         10        ASSIGN                                                   !2, $10
   12    11        TYPE_CHECK                                  1018          !2
         12      > JMPZ                                                     ~12, ->47
   13    13    >   ASSIGN                                                   !4, '%3Cspan+style%3D%27background-color%3Akhaki%3B%27%3E'
   14    14        ASSIGN                                                   !5, '%3C%2Fspan%3E'
   15    15        INIT_FCALL                                               'substr'
         16        SEND_VAR                                                 !0
         17        SEND_VAL                                                 0
         18        SEND_VAR                                                 !2
         19        DO_ICALL                                         $15     
         20        CONCAT                                           ~16     $15, !4
         21        INIT_FCALL                                               'substr'
         22        SEND_VAR                                                 !0
         23        SEND_VAR                                                 !2
         24        STRLEN                                           ~17     !1
         25        SEND_VAL                                                 ~17
         26        DO_ICALL                                         $18     
         27        CONCAT                                           ~19     ~16, $18
         28        CONCAT                                           ~20     ~19, !5
         29        INIT_FCALL                                               'substr'
         30        SEND_VAR                                                 !0
         31        STRLEN                                           ~21     !1
         32        ADD                                              ~22     !2, ~21
         33        SEND_VAL                                                 ~22
         34        STRLEN                                           ~23     !0
         35        SEND_VAL                                                 ~23
         36        DO_ICALL                                         $24     
         37        CONCAT                                           ~25     ~20, $24
         38        ASSIGN                                                   !0, ~25
   16    39        STRLEN                                           ~27     !1
         40        ADD                                              ~28     !2, ~27
         41        STRLEN                                           ~29     !4
         42        ADD                                              ~30     ~28, ~29
         43        STRLEN                                           ~31     !5
         44        ADD                                              ~32     ~30, ~31
         45        ASSIGN                                                   !2, ~32
         46      > JMP                                                      ->48
   18    47    >   ASSIGN                                                   !3, <false>
    8    48    > > JMPNZ                                                    !3, ->5
   22    49    >   ROPE_INIT                                     3  ~36     'html%3D%5B'
         50        ROPE_ADD                                      1  ~36     ~36, !0
         51        ROPE_END                                      2  ~35     ~36, '%5D'
         52        ECHO                                                     ~35
         53      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.34 ms | 1400 KiB | 17 Q