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($needle) + 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/g4XOq
function name:  (null)
number of ops:  54
compiled vars:  !0 = $html, !1 = $search, !2 = $pos, !3 = $loop, !4 = $spanStart, !5 = $spanEnd, !6 = $needle
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                                         $11     
         10        ASSIGN                                                   !2, $11
   12    11        TYPE_CHECK                                  1018          !2
         12      > JMPZ                                                     ~13, ->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                                         $16     
         20        CONCAT                                           ~17     $16, !4
         21        INIT_FCALL                                               'substr'
         22        SEND_VAR                                                 !0
         23        SEND_VAR                                                 !2
         24        STRLEN                                           ~18     !1
         25        SEND_VAL                                                 ~18
         26        DO_ICALL                                         $19     
         27        CONCAT                                           ~20     ~17, $19
         28        CONCAT                                           ~21     ~20, !5
         29        INIT_FCALL                                               'substr'
         30        SEND_VAR                                                 !0
         31        STRLEN                                           ~22     !1
         32        ADD                                              ~23     !2, ~22
         33        SEND_VAL                                                 ~23
         34        STRLEN                                           ~24     !0
         35        SEND_VAL                                                 ~24
         36        DO_ICALL                                         $25     
         37        CONCAT                                           ~26     ~21, $25
         38        ASSIGN                                                   !0, ~26
   16    39        STRLEN                                           ~28     !6
         40        ADD                                              ~29     !2, ~28
         41        STRLEN                                           ~30     !4
         42        ADD                                              ~31     ~29, ~30
         43        STRLEN                                           ~32     !5
         44        ADD                                              ~33     ~31, ~32
         45        ASSIGN                                                   !2, ~33
         46      > JMP                                                      ->48
   18    47    >   ASSIGN                                                   !3, <false>
    8    48    > > JMPNZ                                                    !3, ->5
   22    49    >   ROPE_INIT                                     3  ~37     'html%3D%5B'
         50        ROPE_ADD                                      1  ~37     ~37, !0
         51        ROPE_END                                      2  ~36     ~37, '%5D'
         52        ECHO                                                     ~36
         53      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.46 ms | 1392 KiB | 17 Q