Public feed
#599978
<?php/** * See if a string is a valid hexadecimal colour * * @param string $str Input String * @return bool Returns true if str is a valid hexadecimal colour, false otherwise */ function valid_hex_colour($str){ $len=strlen($str); return (($len==4||$len==7)&&$str[0]=='#'&&strspn(substr($str, 1),'0123456789abcdefABCDEF')==$len-1);}if(valid_hex_colour('#DDd')){ echo "valid!";}else{ echo "invalid!"}?>