3v4l.org

run code in 300+ PHP versions simultaneously
<?php function replaceStrAt($str, $substr, $from, $to = null){ is_null($to) and $to = $from; return mb_substr($str, 0, $from) . $substr . mb_substr($str, $to + 1); } function insertSubstrInto($str, $substr, $index){ return mb_substr($str, 0, $index) . $substr . mb_substr($str, $index); } $s = 'И просто текст'; echo replaceStrAt($s, "\t", 4), "\n"; echo insertSubstrInto($s, "\t", 4), "\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gWdIF
function name:  (null)
number of ops:  16
compiled vars:  !0 = $s
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   ASSIGN                                                   !0, '%D0%98+%D0%BF%D1%80%D0%BE%D1%81%D1%82%D0%BE+%D1%82%D0%B5%D0%BA%D1%81%D1%82'
   13     1        INIT_FCALL                                               'replacestrat'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 '%09'
          4        SEND_VAL                                                 4
          5        DO_FCALL                                      0  $2      
          6        ECHO                                                     $2
          7        ECHO                                                     '%0A'
   14     8        INIT_FCALL                                               'insertsubstrinto'
          9        SEND_VAR                                                 !0
         10        SEND_VAL                                                 '%09'
         11        SEND_VAL                                                 4
         12        DO_FCALL                                      0  $3      
         13        ECHO                                                     $3
         14        ECHO                                                     '%0A'
         15      > RETURN                                                   1

Function replacestrat:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
filename:       /in/gWdIF
function name:  replaceStrAt
number of ops:  22
compiled vars:  !0 = $str, !1 = $substr, !2 = $from, !3 = $to
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV_INIT                                        !3      null
    4     4        TYPE_CHECK                                    2  ~4      !3
          5      > JMPZ_EX                                          ~4      ~4, ->8
          6    >   ASSIGN                                           ~5      !3, !2
          7        BOOL                                             ~4      ~5
    5     8    >   INIT_FCALL                                               'mb_substr'
          9        SEND_VAR                                                 !0
         10        SEND_VAL                                                 0
         11        SEND_VAR                                                 !2
         12        DO_ICALL                                         $6      
         13        CONCAT                                           ~7      $6, !1
         14        INIT_FCALL                                               'mb_substr'
         15        SEND_VAR                                                 !0
         16        ADD                                              ~8      !3, 1
         17        SEND_VAL                                                 ~8
         18        DO_ICALL                                         $9      
         19        CONCAT                                           ~10     ~7, $9
         20      > RETURN                                                   ~10
    6    21*     > RETURN                                                   null

End of function replacestrat

Function insertsubstrinto:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gWdIF
function name:  insertSubstrInto
number of ops:  16
compiled vars:  !0 = $str, !1 = $substr, !2 = $index
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
    8     3        INIT_FCALL                                               'mb_substr'
          4        SEND_VAR                                                 !0
          5        SEND_VAL                                                 0
          6        SEND_VAR                                                 !2
          7        DO_ICALL                                         $3      
          8        CONCAT                                           ~4      $3, !1
          9        INIT_FCALL                                               'mb_substr'
         10        SEND_VAR                                                 !0
         11        SEND_VAR                                                 !2
         12        DO_ICALL                                         $5      
         13        CONCAT                                           ~6      ~4, $5
         14      > RETURN                                                   ~6
    9    15*     > RETURN                                                   null

End of function insertsubstrinto

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.45 ms | 1458 KiB | 16 Q