3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $subject = "any"; $b = " "; $delimited = "$b$subject$b"; $replace = array("?","*","(",")",",","."); $str = "Will *any* company do *any* job, (are there any)?"; //echo "\nThe string: \"$str\""; $temp = str_replace($replace,$b,$str); echo "\n",$temp; while ( ($pos = strpos($temp,$delimited)) !== false ) { echo "\nThe subject \"$subject\" occurs at postion ",($pos + 1); $temp = substr($temp,$pos + 1 + strlen($subject)); }
Output for 5.6.0 - 5.6.30, hhvm-3.15.4, 7.0.0 - 7.3.0beta1
Will any company do any job are there any The subject "any" occurs at postion 6 The subject "any" occurs at postion 14 The subject "any" occurs at postion 18