3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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 "); }
Output for 5.6.0 - 5.6.30, hhvm-3.15.4, 7.0.0 - 7.3.0beta1
int(13)