1

ここで少し問題があります..str_replace最も一般的な単語を置き換えるために使用しています..そして、何らかの理由で、大文字以外のすべての文字を置き換えています.

たとえば、以下のコードがある場合

$str ="Fat string of Text.";    
$commonwords = array('fat','of','random');
$cleantext = str_replace($commonwords,'',$str);

echo $cleantext;

それは反響するだろう..F T

私が間違っていたことについてのアイデア..事前に感謝します

そしてああ..私は試しstr_ireplaceました..しかし何もしませんでした

4

2 に答える 2

4

これは"Fat string Text"をエコーし​​ます。

PHPのインストールが間違っているか、投稿されたコードが実行中のプログラムと完全に一致していない可能性があります

また、"string Text"str_ireplaceをエコーし​​ます。

于 2010-09-04T02:40:42.067 に答える
0

PHP 5.3.3 では再現できません。私は得る:

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.

予想通り。

于 2010-09-04T02:40:44.610 に答える