note 22736 modified in function.ereg by zak

From: Date: Tue, 02 Jul 2002 18:39:41 +0000
Subject: note 22736 modified in function.ereg by zak
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-32514@lists.php.net to get a copy of this message
To ensure that a string contains only alpha and/or numeric data, you can use the following regular expression. if (ereg('^[[:alnum:]]+$', $data)) { echo '$data contains only letters and/or numbers'; } else { echo '$data contains characters other than letters and /or numbers.'; } --was-- Ok. Form validation - Removing Special Characters.... Finally... after every possible combination: !ereg('[^a-zA-Z0-9]',$var) Validates true if no special characters exist.. I hope this saves people the time it took me to figure it out :P http://www.php.net/manual/en/function.ereg.php

« previous php.notes (#32514) next »