3v4l.org

run code in 500+ PHP versions simultaneously
<?php var_dump(remove_last('bla test bla test bla test bla test bla', 'test', ' ')); function remove_last(string $text, string $subject, string $separator): string { $parts = explode($separator, $text); $pos = count($parts) -1 -array_search($subject, array_reverse($parts)); if ($parts[$pos] ?? false) { unset($parts[$pos]); } return implode($separator, $parts); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/X0F13
function name:  (null)
number of ops:  9
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                                   'var_dump'
          1        INIT_FCALL_BY_NAME                                           'remove_last'
          2        SEND_VAL_EX                                                  'bla+test+bla+test+bla+test+bla+test+bla'
          3        SEND_VAL_EX                                                  'test'
          4        SEND_VAL_EX                                                  '+'
          5        DO_FCALL                                          0  $0      
          6        SEND_VAR                                                     $0
          7        DO_ICALL                                                     
   14     8      > RETURN                                                       1

Function remove_last:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 24
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
filename:       /in/X0F13
function name:  remove_last
number of ops:  29
compiled vars:  !0 = $text, !1 = $subject, !2 = $separator, !3 = $parts, !4 = $pos
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    5     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        RECV                                                 !2      
    6     3        INIT_FCALL                                                   'explode'
          4        SEND_VAR                                                     !2
          5        SEND_VAR                                                     !0
          6        DO_ICALL                                             $5      
          7        ASSIGN                                                       !3, $5
    7     8        COUNT                                                ~7      !3
          9        SUB                                                  ~8      ~7, 1
         10        INIT_FCALL                                                   'array_search'
         11        SEND_VAR                                                     !1
         12        INIT_FCALL                                                   'array_reverse'
         13        SEND_VAR                                                     !3
         14        DO_ICALL                                             $9      
         15        SEND_VAR                                                     $9
         16        DO_ICALL                                             $10     
         17        SUB                                                  ~11     ~8, $10
         18        ASSIGN                                                       !4, ~11
    9    19        FETCH_DIM_IS                                         ~13     !3, !4
         20        COALESCE                                             ~14     ~13
         21        QM_ASSIGN                                            ~14     <false>
         22      > JMPZ                                                         ~14, ->24
   10    23    >   UNSET_DIM                                                    !3, !4
   13    24    >   FRAMELESS_ICALL_2                implode             ~15     !2, !3
         25        VERIFY_RETURN_TYPE                                           ~15
         26      > RETURN                                                       ~15
   14    27*       VERIFY_RETURN_TYPE                                           
         28*     > RETURN                                                       null

End of function remove_last

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
153.24 ms | 2009 KiB | 17 Q