str_replace just returns caps
i have a lil problem here..i'm using str_replace
to replace the most common words..and for some reason its replacing every letter except caps.
for example..if i had the code below
$str ="Fat string of Text.";
$commonwords = array('fat','of','ra开发者_运维知识库ndom');
$cleantext = str_replace($commonwords,'',$str);
echo $cleantext;
it would echo.. F T
any ideas what i did wrong.. thanks in advance
and oh..i tried str_ireplace
.. but nothing
This echos "Fat string Text".
Your PHP installation may be wrong or your posted code that does not exactly match the program you are running
Also, str_ireplace
echos "string Text".
Can't reproduce that on PHP 5.3.3. I get:
php > $str ="Fat string of Text.";
php > $commonwords = array('fat','of','random');
php > $cleantext = str_replace($commonwords,'',$str);
php > echo $cleantext;
Fat string Text.
php > $cleantext = str_ireplace($commonwords,'',$str);
php > echo $cleantext;
string Text.
as expected.
精彩评论