Hi all,
I've got a textarea input that I'd like to search for certain words, and strip them out or replace them with ''
What I've got a the moment is giving this error:
Warning: preg_replace() [function.preg-replace]: Delimiter must not be alphanumeric or backslash
From this code
$wordsArray = array("http","www",".com",".net","dot com","dot net");
$arr = explode(" ", strtolower($textArea));
$arrCntr = 0;
foreach ($arr as $info) {
if (in_array($info,$wordsArray)) {
$textArea = preg_replace($wordsArray[$arrCntr], '', $textArea);
}
$arrCntr++;
}
Note: I'd like to do more than simply strip out any html tags and leave behind a web url or a partial url.
Basically, if someone enteres www.a.com or www dot a dot com I'd like to strip out the "www" and the ".com" or "dot com" and not affect a word like "polka dot complete" (not sure why that would be entered, but you get the point 🙂 ). So it needs to be for the specific whole word "dot com" only, in that case.
I'm not too worried about performance as I don't anticipate this code being executed more than 1,000 times a day and the textarea is limited to 250 characters so the input string isn't too big.
Thanks.