Re: Question on explode and join.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I made some changes to the script from Butera. Now it only replaces complete
words.

$dirty = array(
  'ipsum',
  'eloquentiam',
  'Vero'
);

foreach ($dirty as $key => $word) {
   $dirty[$key] = '/\b'. $word . '\b/';
}

$string = "Lorem ipsum ius no etiam veniam, usu alii novum ne, sed cu
molestiae eloquentiam. Vero invenire philosophia est ne, quo nemore timeam
an.";

$clean = preg_replace($dirty, '*', $string);

echo "<br>string: ". $string;
echo "<br>clean: ". $clean;

On 9/13/06, Beauford <php-user@xxxxxxxxxx> wrote:

There ya go. Works and is shorter than what I did. Thanks.

One other question. if I have bunny and bunnyhole in the badword array. if
someone types in bunnyhole, I end up getting *hole in the clean string. If
I
change the order of the words in the array would that solve the problem?

Thanks


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux