Re: Problem
| From: | Steve Edberg | Date: | Fri, 13 Oct 2000 00:11:52 +0000 |
| Subject: | Re: Problem | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-19921@lists.php.net to get a copy of this message | ||
At 02:44 PM 10/12/00 , Fredrik Arild Takle wrote:
Hi. I'm writing some info to a .txt file and I don't want people to submitting the letter a. Can I prevent people from writing this letter? Best Regards Fredrik A. Takle ftakle@online.no --> NOTE: I'm currently not member of this list, can you answer me directly to the email adress above? <--If you want to display an error message, use something like
if (strstr($TextString, 'a')) {
echo "You have an 'a' in your string; please dispose of it!";
} else {
...
# write your text file
...
}
See
http://www.php.net/manual/function.strstr.phpIf you want a case INsensitive comparison, use stristr() function. If you have an older version of PHP3, you can use
if (ereg('a', $TextString)) {
or the case insensitive version
if (eregi('a', $TextString)) {
in place of the
if (strstr($TextString, 'a')) {
line above. If you simply want to remove all instances of 'a', use
$TextString = str_replace('a', '', $TextString);
or
$TextString = ereg_replace('a', '', $TextString);
For more info, see
http://www.php.net/manual/function.str-replace.php-steve +------------------------------------------------------------------------+
| Steve Edberg University of California, Davis | | sbedberg@ucdavis.edu (530)754-9127 | | http://aesric.ucdavis.edu/ http://pgfsun.ucdavis.edu/ |+---------------------- Gort, Klaatu barada nikto! ----------------------+