I've thought about it, and the websafe colors only use CC FF 00 33 66 99. So I could build an array of 216 colors based on that and check against it.
But I also want them to be able to put in other colors, like #9E8F3D for example. Then I remembered that all colors have an RGB value like 255,0,255 but I don't know how to convert and build an array or something to check against.
I've looked at the functions bin2hex hex2dec or the likes (cant remember exact names) but can't tell which one I need to use, or how to build something to check against.
psuedo code:
Code: Select all
if(isValidColor($_POST['color'])){
$color = $_POST['color'];
} else {
$color = '#000000';
}