3v4l.org

run code in 300+ PHP versions simultaneously
<?php var_dump(firstWordPosition('Will company any do any job, (are there any)?', 'any')); function firstWordPosition($str, $word) { // There are others, maybe also pass this in or array_merge() for more control. $nonchars = ['.',',','!','?','(',')','^','$','#','\n','\r\n','\t',]; // You could also do a strpos() with an if and another argument passed in. return stripos(str_replace($nonchars, ' ', " $str "), " $word "); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BLDbX
function name:  (null)
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL_BY_NAME                                       'firstWordPosition'
          2        SEND_VAL_EX                                              'Will+company+any+do+any+job%2C+%28are+there+any%29%3F'
          3        SEND_VAL_EX                                              'any'
          4        DO_FCALL                                      0  $0      
          5        SEND_VAR                                                 $0
          6        DO_ICALL                                                 
   10     7      > RETURN                                                   1

Function firstwordposition:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BLDbX
function name:  firstWordPosition
number of ops:  20
compiled vars:  !0 = $str, !1 = $word, !2 = $nonchars
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    7     2        ASSIGN                                                   !2, <array>
    9     3        INIT_FCALL                                               'stripos'
          4        INIT_FCALL                                               'str_replace'
          5        SEND_VAR                                                 !2
          6        SEND_VAL                                                 '+'
          7        ROPE_INIT                                     3  ~5      '+'
          8        ROPE_ADD                                      1  ~5      ~5, !0
          9        ROPE_END                                      2  ~4      ~5, '+'
         10        SEND_VAL                                                 ~4
         11        DO_ICALL                                         $7      
         12        SEND_VAR                                                 $7
         13        ROPE_INIT                                     3  ~9      '+'
         14        ROPE_ADD                                      1  ~9      ~9, !1
         15        ROPE_END                                      2  ~8      ~9, '+'
         16        SEND_VAL                                                 ~8
         17        DO_ICALL                                         $11     
         18      > RETURN                                                   $11
   10    19*     > RETURN                                                   null

End of function firstwordposition

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
177.73 ms | 1396 KiB | 19 Q