3v4l.org

run code in 500+ PHP versions simultaneously
<?php /** * replace only the first occurance of str math * */ function str_replace_first_only($from, $to, $content,$count) { $from = '/'.preg_quote($from, '/').'/'; return preg_replace($from, $to, $content, $count); // remove only first occurance } $patha = 'BIN/BIN/test.php'; $count = 1; $pathb = str_replace_first_only('BIN', 'SYSTEM', $patha, $count); echo $pathb; ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/OaVcP
function name:  (null)
number of ops:  11
compiled vars:  !0 = $patha, !1 = $count, !2 = $pathb
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   12     0  E >   ASSIGN                                                       !0, 'BIN%2FBIN%2Ftest.php'
   13     1        ASSIGN                                                       !1, 1
   14     2        INIT_FCALL                                                   'str_replace_first_only'
          3        SEND_VAL                                                     'BIN'
          4        SEND_VAL                                                     'SYSTEM'
          5        SEND_VAR                                                     !0
          6        SEND_VAR                                                     !1
          7        DO_FCALL                                          0  $5      
          8        ASSIGN                                                       !2, $5
   15     9        ECHO                                                         !2
   16    10      > RETURN                                                       1

Function str_replace_first_only:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/OaVcP
function name:  str_replace_first_only
number of ops:  19
compiled vars:  !0 = $from, !1 = $to, !2 = $content, !3 = $count
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    6     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        RECV                                                 !2      
          3        RECV                                                 !3      
    8     4        INIT_FCALL                                                   'preg_quote'
          5        SEND_VAR                                                     !0
          6        SEND_VAL                                                     '%2F'
          7        DO_ICALL                                             $4      
          8        CONCAT                                               ~5      '%2F', $4
          9        CONCAT                                               ~6      ~5, '%2F'
         10        ASSIGN                                                       !0, ~6
    9    11        INIT_FCALL                                                   'preg_replace'
         12        SEND_VAR                                                     !0
         13        SEND_VAR                                                     !1
         14        SEND_VAR                                                     !2
         15        SEND_VAR                                                     !3
         16        DO_ICALL                                             $8      
         17      > RETURN                                                       $8
   10    18*     > RETURN                                                       null

End of function str_replace_first_only

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
158.58 ms | 2113 KiB | 16 Q