3v4l.org

run code in 300+ PHP versions simultaneously
<?php $s = '<li id="item" class="list-item" href="#">Item</li><li id="item" class="list-item" href="#">Item</li>'; $find = "li"; $lenght = strlen($find); $pos1 = strpos($s, $find); $pos2 = strrpos($s, $find); Echo substr($s,0,$pos1) . "a" . Substr($s,$pos1+$lenght,$pos2-$lenght-1) . "a" . Substr($s,$pos2+$lenght); //Echo str_replace(array("<li ", "</li>"), array("<a ", "</a>"), $s);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EdaM4
function name:  (null)
number of ops:  38
compiled vars:  !0 = $s, !1 = $find, !2 = $lenght, !3 = $pos1, !4 = $pos2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3Cli+id%3D%22item%22+class%3D%22list-item%22+href%3D%22%23%22%3EItem%3C%2Fli%3E%3Cli+id%3D%22item%22+class%3D%22list-item%22+href%3D%22%23%22%3EItem%3C%2Fli%3E'
    4     1        ASSIGN                                                   !1, 'li'
    5     2        STRLEN                                           ~7      !1
          3        ASSIGN                                                   !2, ~7
    6     4        INIT_FCALL                                               'strpos'
          5        SEND_VAR                                                 !0
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                         $9      
          8        ASSIGN                                                   !3, $9
    7     9        INIT_FCALL                                               'strrpos'
         10        SEND_VAR                                                 !0
         11        SEND_VAR                                                 !1
         12        DO_ICALL                                         $11     
         13        ASSIGN                                                   !4, $11
    9    14        INIT_FCALL                                               'substr'
         15        SEND_VAR                                                 !0
         16        SEND_VAL                                                 0
         17        SEND_VAR                                                 !3
         18        DO_ICALL                                         $13     
         19        CONCAT                                           ~14     $13, 'a'
         20        INIT_FCALL                                               'substr'
         21        SEND_VAR                                                 !0
         22        ADD                                              ~15     !3, !2
         23        SEND_VAL                                                 ~15
         24        SUB                                              ~16     !4, !2
         25        SUB                                              ~17     ~16, 1
         26        SEND_VAL                                                 ~17
         27        DO_ICALL                                         $18     
         28        CONCAT                                           ~19     ~14, $18
         29        CONCAT                                           ~20     ~19, 'a'
         30        INIT_FCALL                                               'substr'
         31        SEND_VAR                                                 !0
         32        ADD                                              ~21     !4, !2
         33        SEND_VAL                                                 ~21
         34        DO_ICALL                                         $22     
         35        CONCAT                                           ~23     ~20, $22
         36        ECHO                                                     ~23
   11    37      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.02 ms | 1396 KiB | 19 Q