Hi
I want to replace a word from text. I can do it with str_replace or str_ireplace. But I need more advance. for Example. my code is as below
<?php
$search_word=$_POST['gender'];
$subject="Men and Women both r part of the world";
echo str_ireplace($search_word, '<span style="background:#0F0">' . $search_word . '</span>',
$subject)."<br/>";
echo str_replace($search_word, '<span style="background:#0F0">' . $search_word . '</span>',
$subject)."<br/>";
$search_1=str_replace($search_word, '<span style="background:#0F0">' . $search_word . '</span>',
$subject)."<br/>";
$search_2=str_ireplace($search_word, '<span style="background:#0F0">' . $search_word . '</span>',
$search_1)."<br/>";
echo $search_2;
?>
in first echo it is showing Both 'Men' and 'men' background color changed but 'men' replaced to 'Men'
in second echo it is showing Onle 'Men' background color changed
in third echo it is showing Both 'Men' and 'men' background color changed but 'men' replaced to 'Men'
But I want that background color of both 'Men' & 'men' will be changed but word should be remain its original case.
here $_POST['gender'] may be 'men' or 'MEN' or 'mEn' or 'danIwEb' etc. (any word and any character)
is it possible? plz help me.