eregi_replace?
am 08.11.2007 00:14:28 von PupkinHi,
I need a case-insensitive replace function to run a string.
I've tried to substitute eregi_replace for str_replace, but it doesn't
seem to work with my array of replaceable terms (it did work on a simple
test, however).
I'm taking a string submitted from a form and flagging words that may
not comply with a set of standards, so that an editor can easily spot
them and decide what to do with them.
Right now it's set-up pretty much like this on my test page:
//simulated string from the form
$ad_text = "THIS STRING IS EMPLOYED TO FLAG REQUIRED LIST OF UNLAWFUL
SINGLE TERMS!";
?>
Unfiltered Text: = $ad_text ?>
$bad_words = array('employed', 'law', 'required', 'single');
$flag_bad_words = array('employed**', 'law**', 'required**',
'single**');
//works, but only case-sensitive
//$ad_text = str_replace($bad_words, $flag_bad_words, $ad_text);
//doesn't work at all
$ad_text = eregi_replace($bad_words, $flag_bad_words, $ad_text);
?>
Filtered Text: = $ad_text ?>