English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

it would help if the word is contained within the form

for example, filter would find "cycle" in "motorcycle" and block it

2007-01-31 04:13:52 · 3 answers · asked by shaunhelsom 2 in Computers & Internet Programming & Design

3 answers

You can use replace functions

http://www.php.net/manual/en/function.ereg-replace.php
http://www.php.net/manual/en/function.str-replace.php

these should help.

RJ

2007-01-31 04:21:07 · answer #1 · answered by Anonymous · 0 0

Preg_match is the best way...learn about regular expressions as its way to complex to go into here. For instance, if you were making a profanity filter, and someone innocently entered the place name Scunthorpe, you would not want this to be blocked, but it contains what may be seen as a rude word.
I use a program called regex buddy which is good for learning and experimenting with regexes

2007-01-31 10:23:31 · answer #2 · answered by coffeeaddict_uk 3 · 0 0

There are a number of functions in PHP which will do this for you... the easiest one is str_replace --


$string = "This is a test";
echo str_replace(" is", " was", $string);
?>

2007-01-31 06:52:50 · answer #3 · answered by Thomas H 3 · 0 0

fedest.com, questions and answers