Page 1 of 1

1337ifier

Posted: Mon May 24, 2004 8:02 am
by Dingbats
I'm trying to make a 1337ifier for my site. You type in some text and press a button, and the text is converted to 1337sp33k. But:

When you use str_replace() or ereg_replace() to change for example "you" to "yuo", it changes all occurences of "you". But I want to change some "you" to "yuo" and some to "j00". How would I do that? I guess I could use explode() in some way, but I don't know how.

Posted: Mon May 24, 2004 8:38 am
by feyd

Code: Select all

$replaceWord = array('you'=>array('yuo','j00'));
foreach($replaceWord as $word => $rep)
{
  $max = preg_match_all("=\b$word\b=i",$string);
  preg_replace("=\b$word\b=i",$rep[mt_rand() % sizeof($rep)],$string,1);
}
not tested