3v4l.org

run code in 500+ PHP versions simultaneously
<?php function substrStrpos($text) { return substr($text, 1 + (strpos($text, ' ') ?: -1)); } function explodeSlice($text) { $explodeOnce = explode(' ', $text, 2); return array_pop($explodeOnce); } function substrStrstr($text) { return substr(strstr($text, " "), 1); } function ltrimStrstr($text) { return ltrim(strstr($text, " ")); } function pregReplace($text) { return preg_replace('~^\S+\s*~', '', $text); } $tests = [ '' => '', 'White' => '', 'White Tank' => 'Tank', 'White Tank Top' => 'Tank Top', ]; printf("| %14s| [empty] | White | White Tank | White Tank Top |\n", 'func \ tests'); $funcs = [ 'substrStrpos', 'explodeSlice', 'substrStrstr', 'ltrimStrstr', 'pregReplace', ]; foreach ($funcs as $func) { echo "------------------------------------------------------------------------\n"; printf( "| %14s| %s | %s | %s | %s |\n", $func, ...array_map( fn($result, $expected) => $result === $expected ? '✅': '💩', array_map($func, array_keys($tests)), $tests ) ); } echo "\n\n---\n"; var_export(substrStrpos('White')); echo "\n\n---\n"; var_export(explodeSlice('White'));
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 29
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 29
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
filename:       /in/RqTSW
function name:  (null)
number of ops:  45
compiled vars:  !0 = $tests, !1 = $funcs, !2 = $func
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   24     0  E >   ASSIGN                                                       !0, <array>
   31     1        INIT_FCALL                                                   'printf'
          2        SEND_VAL                                                     '%7C+%2514s%7C++%5Bempty%5D++%7C++White++%7C++White+Tank++%7C++White+Tank+Top++%7C%0A'
          3        SEND_VAL                                                     'func+%5C+tests'
          4        DO_ICALL                                                     
   32     5        ASSIGN                                                       !1, <array>
   40     6      > FE_RESET_R                                           $6      !1, ->29
          7    > > FE_FETCH_R                                                   $6, !2, ->29
   41     8    >   ECHO                                                         '------------------------------------------------------------------------%0A'
   42     9        INIT_FCALL                                                   'printf'
   43    10        SEND_VAL                                                     '%7C+%2514s%7C++++%25s++++%7C++++%25s+++%7C++++++%25s++++++%7C++++++++%25s+++++++%7C%0A'
   44    11        SEND_VAR                                                     !2
   45    12        INIT_FCALL                                                   'array_map'
   46    13        DECLARE_LAMBDA_FUNCTION                              ~7      [0]
         14        SEND_VAL                                                     ~7
   47    15        INIT_FCALL                                                   'array_map'
         16        SEND_VAR                                                     !2
         17        INIT_FCALL                                                   'array_keys'
         18        SEND_VAR                                                     !0
         19        DO_ICALL                                             $8      
         20        SEND_VAR                                                     $8
         21        DO_ICALL                                             $9      
         22        SEND_VAR                                                     $9
   48    23        SEND_VAR                                                     !0
   45    24        DO_ICALL                                             $10     
   48    25        SEND_UNPACK                                                  $10
         26        CHECK_UNDEF_ARGS                                             
   42    27        DO_ICALL                                                     
   40    28      > JMP                                                          ->7
         29    >   FE_FREE                                                      $6
   53    30        ECHO                                                         '%0A%0A---%0A'
   54    31        INIT_FCALL                                                   'var_export'
         32        INIT_FCALL                                                   'substrstrpos'
         33        SEND_VAL                                                     'White'
         34        DO_FCALL                                          0  $12     
         35        SEND_VAR                                                     $12
         36        DO_ICALL                                                     
   55    37        ECHO                                                         '%0A%0A---%0A'
   56    38        INIT_FCALL                                                   'var_export'
         39        INIT_FCALL                                                   'explodeslice'
         40        SEND_VAL                                                     'White'
         41        DO_FCALL                                          0  $14     
         42        SEND_VAR                                                     $14
         43        DO_ICALL                                                     
         44      > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RqTSW
function name:  {closure:/in/RqTSW:46}
number of ops:  9
compiled vars:  !0 = $result, !1 = $expected
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   46     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        IS_IDENTICAL                                                 !0, !1
          3      > JMPZ                                                         ~2, ->6
          4    >   QM_ASSIGN                                            ~3      '%E2%9C%85'
          5      > JMP                                                          ->7
          6    >   QM_ASSIGN                                            ~3      '%F0%9F%92%A9'
          7    > > RETURN                                                       ~3
          8*     > RETURN                                                       null

End of Dynamic Function 0

Function substrstrpos:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RqTSW
function name:  substrStrpos
number of ops:  8
compiled vars:  !0 = $text
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
    4     1        FRAMELESS_ICALL_2                strpos              ~1      !0, '+'
          2        JMP_SET                                              ~2      ~1, ->4
          3        QM_ASSIGN                                            ~2      -1
          4        ADD                                                  ~3      1, ~2
          5        FRAMELESS_ICALL_2                substr              ~4      !0, ~3
          6      > RETURN                                                       ~4
    5     7*     > RETURN                                                       null

End of function substrstrpos

Function explodeslice:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RqTSW
function name:  explodeSlice
number of ops:  12
compiled vars:  !0 = $text, !1 = $explodeOnce
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    7     0  E >   RECV                                                 !0      
    8     1        INIT_FCALL                                                   'explode'
          2        SEND_VAL                                                     '+'
          3        SEND_VAR                                                     !0
          4        SEND_VAL                                                     2
          5        DO_ICALL                                             $2      
          6        ASSIGN                                                       !1, $2
    9     7        INIT_FCALL                                                   'array_pop'
          8        SEND_REF                                                     !1
          9        DO_ICALL                                             $4      
         10      > RETURN                                                       $4
   10    11*     > RETURN                                                       null

End of function explodeslice

Function substrstrstr:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RqTSW
function name:  substrStrstr
number of ops:  5
compiled vars:  !0 = $text
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   12     0  E >   RECV                                                 !0      
   13     1        FRAMELESS_ICALL_2                strstr              ~1      !0, '+'
          2        FRAMELESS_ICALL_2                substr              ~2      ~1, 1
          3      > RETURN                                                       ~2
   14     4*     > RETURN                                                       null

End of function substrstrstr

Function ltrimstrstr:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RqTSW
function name:  ltrimStrstr
number of ops:  7
compiled vars:  !0 = $text
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   16     0  E >   RECV                                                 !0      
   17     1        INIT_FCALL                                                   'ltrim'
          2        FRAMELESS_ICALL_2                strstr              ~1      !0, '+'
          3        SEND_VAL                                                     ~1
          4        DO_ICALL                                             $2      
          5      > RETURN                                                       $2
   18     6*     > RETURN                                                       null

End of function ltrimstrstr

Function pregreplace:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RqTSW
function name:  pregReplace
number of ops:  5
compiled vars:  !0 = $text
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   20     0  E >   RECV                                                 !0      
   21     1        FRAMELESS_ICALL_3                preg_replace        ~1      '%7E%5E%5CS%2B%5Cs%2A%7E', ''
          2        OP_DATA                                                      !0
          3      > RETURN                                                       ~1
   22     4*     > RETURN                                                       null

End of function pregreplace

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
169.73 ms | 1758 KiB | 22 Q