johnsmith153 Posted October 11, 2008 Share Posted October 11, 2008 I need to get the last 2 digits of a hex value and see if they are in the first half or last. Ie RGB 255 - I need to see if the figure (in hex) is less than 128 HEX #xxxxFF - yes as no as this 255 HEX #xxxx64 - yes as this is 100 Does this make sense? Link to comment https://forums.phpfreaks.com/topic/128044-convert-hex-to-rgb/ Share on other sites More sharing options...
AV1611 Posted October 11, 2008 Share Posted October 11, 2008 So, You want to convert the hex AABBCC to decimal XXXYYYZZZ then take the last set and subtract 128 and see if it's a positive number or not? http://us2.php.net/hexdec <?php var_dump(hexdec("See")); var_dump(hexdec("ee")); // both print "int(238)" var_dump(hexdec("that")); // print "int(10)" var_dump(hexdec("a0")); // print "int(160)" ?> Link to comment https://forums.phpfreaks.com/topic/128044-convert-hex-to-rgb/#findComment-663041 Share on other sites More sharing options...
Barand Posted October 11, 2008 Share Posted October 11, 2008 $colour = 'C0FFEE'; list ($r, $g, $b) = sscanf($colour, '%02X%02X%02X'); echo $b < 128 ? 'Yes' : 'No'; Link to comment https://forums.phpfreaks.com/topic/128044-convert-hex-to-rgb/#findComment-663051 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.