Removing a word from a TEXTAREA?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rxsid
Forum Commoner
Posts: 82
Joined: Thu Aug 29, 2002 12:04 am

Removing a word from a TEXTAREA?

Post by rxsid »

Hi all,

I have a form with a <textarea> on it. I don't want to allow things such as email addresses or website url's.
After the form is submitted, how can I use PHP to remove those items? In other words, can I delete a single word in a textarea?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

after the form is submitted it doesn't matter to php where the paramter came from (input text, - hidden, textarea, ...). So your question turns out to be "How can I delete certain words from a string in php".
For what you've described I suggest mixed preg_replace ( mixed pattern, mixed replacement, mixed subject [, int limit]) to replace all ocurrences of what seems to be an email-address or url.
There have been several threads on the topic what pattern to use to detect urls or emails-addresses, e.g. viewtopic.php?t=2369
But feel free to search another. I tried "pattern AND url" and "pattern AND email".
Post Reply