I need to replace the substring with any string in upper or lower case
$sub = "STR"; $newsub="All-"; $str="Strstring"; $newstr=str_replace($sub,$rep,$str);
You can use the str_ireplacePHP function as
str_ireplace
$sub = "STR"; $newsub="All-"; $str="Strstring"; $newstr=str_ireplace($sub,$newsub,$str);
Fiddle
You can also use preg_replace-
preg_replace
$sub = array('/STR/i'); $newsub="All-"; $str="Strstring"; echo $newstr=preg_replace($sub, $newsub, $str);
Output
All-All-ing