[PHP]Converting RGB or HEX To “Long Int” Color?

You should be able to use PHP's hexdec function.

You should be able to use PHP's hexdec function. Hexdec('FFFFFF'): 16777215 hexdec('123456'): 1193046 etc. Are you saying these values aren't correct? Or were you using dechex instead by mistake?

Update based on your comment which says that color "#123456" should be "5649426" in "Long Int" format: 5649426 in base 16 is 0x563412, so it's clear your format requires BGR instead of RGB. So just build a "BGR" string from your "RGB" string first then feed it to hexdec: $rgb = '123456'; $bgr = substr($rgb,4,2) . Substr($rgb,2,2) .

Substr($rgb,0,2); print hexdec($bgr); yields 5649426.

That was a typo in the question, my bad. R18, G52, R86/#123456 == 5649426 in "Long Int", and that was where hexdec results were not matching up w/ the color-picker conversion. :/ – phpwns Sep 3 '10 at 2:47 Sweet, I was wondering if the color order was different then standard RGB but didn't mess around with it enough, thanks!

– phpwns Sep 3 '10 at 14:49.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions