View Single Post
Old 10-23-2007, 01:04 AM   #8 (permalink)
Salathe
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

On the topic of validating the hexadecimal colour string, if you don't care too much about wasted ten-thousands of a second, you could simply use:
PHP Code:
function is_colour($hex)
{
    return (bool) 
preg_match('/^#?[a-fA-F0-9]{6}$/'$hex);

Salathe is offline  
Reply With Quote