Hello.
I convert a hex colour code to RGB using this code;
$Red = hexdec(substr($_POST['colour'], 0, 2));
$Green = hexdec(substr($_POST['colour'], 2, 2));
$Blue = hexdec(substr($_POST['colour'], 4, 2));
The problem i am having is trying to change it back. I nearly got it, but not quite.
The 000's get stored as just a single 0, and 004 as 4 etc. This resulted in '00FF00' getting changed back as '0FF0' which isnt correct.
I tried to fix the problem with something like the following;
$OneHex = DecHex(str_pad($myrow['Red'],3,"0"));
$TwoHex = DecHex(str_pad($myrow['Green'],3,"0"));
$ThreeHex = DecHex(str_pad($myrow['Blue'],3,"0"));
But i end up with the same as before.
Any ideas?
Thanks!