Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

PHP Regex - Hex color codes. - PHP Code Bank


PHP Regex - Hex color codes.
This script checks if $string is a valid Hex color code.
                <?php
	$string = "#FF0000";
	
	if (preg_match('/^#(?:(?:[a-f\d]{3}){1,2})$/i', $string)) 
	{
		echo "This is a valid HEX Color code!";
	}
	else
	{
		echo "This is not a valid HEX Color code!";
	}
?>
            
Comments
Sorry but there are no comments to display