RE: [PHP] Question on explode and join.

From: Date: Thu, 14 Sep 2006 12:42:01 +0000
Subject: RE: [PHP] Question on explode and join.
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-241774@lists.php.net to get a copy of this message
At 5:55 PM -0400 9/13/06, Beauford wrote:
The problem with scripts like these is there is so many variables to deal with. First, this doesn't deal with uppercase. So a word like bAdWoRd would not get detected, or a word beginning a sentence. Also, a word within a word like wordbadwordword would not be detected, and I'm sure there are more I haven't discovered yet. I haven't had much time to play around with it since earlier today, so I haven't experimented with it, but ideas are welcome.
The problem of wordbadwordword is not solvable unless you have a dictionary of acceptable words as well. For example, words like "assumption" and "hellacious" would be problematic. Furthermore, there are words that are perfectly acceptable, but their meanings differ in context, like "screw". So you would need a context checker, which presents its own problems. tedd
Thanks -----Original Message----- From: Ducarom [mailto:ducarom@gmail.com] Sent: September 13, 2006 2:26 PM To: Beauford Cc: php Subject: Re: [PHP] Question on explode and join. 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@netscan.ca> 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
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
-- ------- http://sperling.com http://ancientstones.com http://earthstones.com

« previous php.general (#241774) next »