Jump to content

PHP str_replace same subject as variable


Ceox

Recommended Posts

Hey,

I have many words in an array, that I need to replace with other text in a sentence.

Here's what I got:

$bfile = file("banned_words.txt");

$toclean = $words;

 

	
$bfile = file("banned_words.txt"); // one word on each row

for($i = 0; $i < count($bfile); $i++)
{
$replace = "xxx";

$toclean = str_replace($bfile[$i], $replace, $toclean);
}

 

This only replaces the last word in the array.

What can I do to make it work?

 

- Max

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.