note 29587 modified in function.ereg by tix
| From: | tix@php.net | Date: | Tue, 18 Feb 2003 13:54:33 +0000 |
| Subject: | note 29587 modified in function.ereg by tix | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-44149@lists.php.net to get a copy of this message | ||
This is probably really simple, but if anyone wants to validate a variable $COLOUR to ensure is a
valid HEX value, you can use this...
if (ereg ('^#([a-fA-F0-9]){6}$', $COLOUR) == false || strlen($COLOUR) != 7) {
echo "Isn't a valid HEX value";
}
--was--
This is probably really simple, but if anyone wants to validate a variable $COLOUR to ensure is a
valid HEX value, you can use this...
if (ereg ('^#([a-fA-F0-9]){6}', $COLOUR) == false || strlen($COLOUR) != 7) {
echo "Isn't a valid HEX value";
}
http://www.php.net/manual/en/function.ereg.php