3v4l.org

run code in 300+ PHP versions simultaneously
<?php function remove_after($needle, $haystack, $removeNeedle = false) { $needle = preg_quote($needle) . ($removeNeedle ? '' : '\K'); return preg_replace("#.*\K$needle.*#s", '', $haystack); } var_dump(remove_after("cheese", "The cheese is good and the cheese is yummy")); var_dump(remove_after("cheese", "The cheese is good and the cheese is yummy", true));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/H6mdm
function name:  (null)
number of ops:  16
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'remove_after'
          2        SEND_VAL                                                 'cheese'
          3        SEND_VAL                                                 'The+cheese+is+good+and+the+cheese+is+yummy'
          4        DO_FCALL                                      0  $0      
          5        SEND_VAR                                                 $0
          6        DO_ICALL                                                 
   10     7        INIT_FCALL                                               'var_dump'
          8        INIT_FCALL                                               'remove_after'
          9        SEND_VAL                                                 'cheese'
         10        SEND_VAL                                                 'The+cheese+is+good+and+the+cheese+is+yummy'
         11        SEND_VAL                                                 <true>
         12        DO_FCALL                                      0  $2      
         13        SEND_VAR                                                 $2
         14        DO_ICALL                                                 
         15      > RETURN                                                   1

Function remove_after:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/H6mdm
function name:  remove_after
number of ops:  22
compiled vars:  !0 = $needle, !1 = $haystack, !2 = $removeNeedle
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      <false>
    5     3        INIT_FCALL                                               'preg_quote'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $3      
          6      > JMPZ                                                     !2, ->9
          7    >   QM_ASSIGN                                        ~4      ''
          8      > JMP                                                      ->10
          9    >   QM_ASSIGN                                        ~4      '%5CK'
         10    >   CONCAT                                           ~5      $3, ~4
         11        ASSIGN                                                   !0, ~5
    6    12        INIT_FCALL                                               'preg_replace'
         13        ROPE_INIT                                     3  ~8      '%23.%2A%5CK'
         14        ROPE_ADD                                      1  ~8      ~8, !0
         15        ROPE_END                                      2  ~7      ~8, '.%2A%23s'
         16        SEND_VAL                                                 ~7
         17        SEND_VAL                                                 ''
         18        SEND_VAR                                                 !1
         19        DO_ICALL                                         $10     
         20      > RETURN                                                   $10
    7    21*     > RETURN                                                   null

End of function remove_after

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.44 ms | 1014 KiB | 18 Q