╰┈➤ Create a function that determines whether a string is a valid hex code. The hex code must begin with a pound key # and is exactly 6 characters in length. Each character must be a digit from 0-9 or an alphabetic character from A-F. All alphabetic characters may be uppercase or lowercase. ◄
function isSpecialArray($str) {
    $length = strlen($str);
    $count=1;
    for ($i=1; $i<$length; $i++) {
	if ($str[0]="#") {
	    
► // 0123456789abcdefABCDEF
if ((ord($str[$i]) > 64 && ord($str[$i]) < 71) || (ord($str[$i]) > 47 && ord($str[$i]) < 58) || (ord($str[$i]) > 96 && ord($str[$i]) < 103)) { $count+=1; } } } if (strlen($str)==7 && $count==$length){ return true; } return false; } var_dump(isSpecialArray("#CD5C5B"));
`
by Luka Khitaridze
2 years ago
PHP
Problem solving
0
Pro tip: use ```triple backticks around text``` to write in code fences