3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $subject = "any"; $b = " "; $delimited = "$b$subject$b"; $str = "Will *any* company do *any* job, (are there any)?"; echo "\nThe string: \"$str\""; $temp = $str; for ($i=0, $max = strlen($temp); $i < $max; $i++) { if (!ctype_alpha($temp[$i]) ){ $temp[$i] = $b; } } while ( ($pos = strpos($temp,$delimited)) !== false ) { echo "\nThe subject \"$subject\" occurs at position ",($pos + 1); for ($i=0,$max=$pos + 1 + strlen($subject); $i <= $max; $i++) { $temp[$i] = $b; } }
Output for 5.6.0 - 5.6.30, hhvm-3.15.4, 7.0.0 - 7.3.0beta1
The string: "Will *any* company do *any* job, (are there any)?" The subject "any" occurs at position 6 The subject "any" occurs at position 23 The subject "any" occurs at position 44