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 "); }

preferences:
56.94 ms | 402 KiB | 5 Q