3v4l.org

run code in 300+ PHP versions simultaneously
<?php function str_replace_chr(string $str, int $position, string $format): string { $chr = $str[$position - 1]; $p1 = $position - 1; $p2 = ($p1 + 1 ) - strlen($str); $replace = sprintf($format,$chr); return substr_replace($str,$replace,$p1,$p2); } echo str_replace_chr('VietJack Team', 5, '<span style="color: red;">%s</span>');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hvv3p
function name:  (null)
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   INIT_FCALL                                               'str_replace_chr'
          1        SEND_VAL                                                 'VietJack+Team'
          2        SEND_VAL                                                 5
          3        SEND_VAL                                                 '%3Cspan+style%3D%22color%3A+red%3B%22%3E%25s%3C%2Fspan%3E'
          4        DO_FCALL                                      0  $0      
          5        ECHO                                                     $0
          6      > RETURN                                                   1

Function str_replace_chr:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hvv3p
function name:  str_replace_chr
number of ops:  27
compiled vars:  !0 = $str, !1 = $position, !2 = $format, !3 = $chr, !4 = $p1, !5 = $p2, !6 = $replace
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
    7     3        SUB                                              ~7      !1, 1
          4        FETCH_DIM_R                                      ~8      !0, ~7
          5        ASSIGN                                                   !3, ~8
    9     6        SUB                                              ~10     !1, 1
          7        ASSIGN                                                   !4, ~10
   10     8        ADD                                              ~12     !4, 1
          9        STRLEN                                           ~13     !0
         10        SUB                                              ~14     ~12, ~13
         11        ASSIGN                                                   !5, ~14
   12    12        INIT_FCALL                                               'sprintf'
         13        SEND_VAR                                                 !2
         14        SEND_VAR                                                 !3
         15        DO_ICALL                                         $16     
         16        ASSIGN                                                   !6, $16
   14    17        INIT_FCALL                                               'substr_replace'
         18        SEND_VAR                                                 !0
         19        SEND_VAR                                                 !6
         20        SEND_VAR                                                 !4
         21        SEND_VAR                                                 !5
         22        DO_ICALL                                         $18     
         23        VERIFY_RETURN_TYPE                                       $18
         24      > RETURN                                                   $18
   15    25*       VERIFY_RETURN_TYPE                                       
         26*     > RETURN                                                   null

End of function str_replace_chr

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.46 ms | 1006 KiB | 16 Q