My name is Roi and I need your help.
Hope you will be able to help me-
I wrote a script that take variable that contain HTML code,. it replace the exact word "php" (no matter if it is contain capital letters) with the word "asp"
for example, if the variable contain:
Code: Select all
<a href='http://www.php.com'>myphp</a> best <b>php</b> website <h1>PhP!!!</h1> php and myphp or phpme - <u>php!</u>!Code: Select all
<a href='http://www.asp.com'>myphp</a> best <b>asp</b> website <h1>asp!!!</h1> aspand myphp or phpme - <u>asp!</u>!Here is my code:
Code: Select all
function keepcase($word, $replace) {
$replace[0] = (ctype_upper($word[0]) ? strtoupper($replace[0]) : $replace[0]);
return $replace;
}
$text = strtolower(file_get_contents($folder.$file));
$replace = "asp";
$word = "php";
$output = preg_replace('/\b' . preg_quote($word) . '\b/ei', "keepcase('\\0', '$replace')", $text);
echo $output; Thank you in advance,
Roi.