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/EKS7J
function name:  (null)
number of ops:  21
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
   11    14        INIT_FCALL                                               'str_replace'
         15        SEND_VAL                                                 <array>
         16        SEND_VAL                                                 <array>
         17        SEND_VAR                                                 !0
         18        DO_ICALL                                         $13     
         19        ECHO                                                     $13
         20      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.59 ms | 1395 KiB | 19 Q