3v4l.org

run code in 300+ PHP versions simultaneously
<?php function _deep_replace( $search, $subject ) { $subject = (string) $subject; $count = 1; while ( $count ) { $subject = str_replace( $search, '', $subject, $count ); } return $subject; } $foo = '*123123123ABCABCABC*'; var_dump( str_replace( '123ABC', '', $foo ) ); var_dump( _deep_replace( '123ABC', $foo ) ); var_dump( preg_replace('/123ABC+/', '', $foo ) ); var_dump( strtr( $foo, array( '123ABC' => '' ) ) );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pTHu7
function name:  (null)
number of ops:  32
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   ASSIGN                                                   !0, '%2A123123123ABCABCABC%2A'
   13     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'str_replace'
          3        SEND_VAL                                                 '123ABC'
          4        SEND_VAL                                                 ''
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $2      
          7        SEND_VAR                                                 $2
          8        DO_ICALL                                                 
   14     9        INIT_FCALL                                               'var_dump'
         10        INIT_FCALL                                               '_deep_replace'
         11        SEND_VAL                                                 '123ABC'
         12        SEND_VAR                                                 !0
         13        DO_FCALL                                      0  $4      
         14        SEND_VAR                                                 $4
         15        DO_ICALL                                                 
   15    16        INIT_FCALL                                               'var_dump'
         17        INIT_FCALL                                               'preg_replace'
         18        SEND_VAL                                                 '%2F123ABC%2B%2F'
         19        SEND_VAL                                                 ''
         20        SEND_VAR                                                 !0
         21        DO_ICALL                                         $6      
         22        SEND_VAR                                                 $6
         23        DO_ICALL                                                 
   16    24        INIT_FCALL                                               'var_dump'
         25        INIT_FCALL                                               'strtr'
         26        SEND_VAR                                                 !0
         27        SEND_VAL                                                 <array>
         28        DO_ICALL                                         $8      
         29        SEND_VAR                                                 $8
         30        DO_ICALL                                                 
         31      > RETURN                                                   1

Function _deep_replace:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 6
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 6
Branch analysis from position: 14
Branch analysis from position: 6
filename:       /in/pTHu7
function name:  _deep_replace
number of ops:  16
compiled vars:  !0 = $search, !1 = $subject, !2 = $count
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    3     2        CAST                                          6  ~3      !1
          3        ASSIGN                                                   !1, ~3
    5     4        ASSIGN                                                   !2, 1
    6     5      > JMP                                                      ->13
    7     6    >   INIT_FCALL                                               'str_replace'
          7        SEND_VAR                                                 !0
          8        SEND_VAL                                                 ''
          9        SEND_VAR                                                 !1
         10        SEND_REF                                                 !2
         11        DO_ICALL                                         $6      
         12        ASSIGN                                                   !1, $6
    6    13    > > JMPNZ                                                    !2, ->6
   10    14    > > RETURN                                                   !1
   11    15*     > RETURN                                                   null

End of function _deep_replace

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.72 ms | 1394 KiB | 22 Q