michaellunsford Posted January 19, 2007 Share Posted January 19, 2007 I'm wanting to convert a web color, like FF0000 to an RGB value, 255,0,0. I was going to substr the web color and make my own math function. Before I do all that, is there a built-in function that does this already? Or something close?Thanks! Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 19, 2007 Share Posted January 19, 2007 Did you try googling it?I found several results for convert hex to rgb in php Quote Link to comment Share on other sites More sharing options...
redbullmarky Posted January 19, 2007 Share Posted January 19, 2007 [url=http://uk2.php.net/hex2dec]hex2dec[/url] should set you on your way ;)you'll just have to note that each pair in the 6 character hex string amounts to a number, so you will (as far as i know, unless there's another specific function) have to split it up first into 3 parts and then perform the hex2dec conversions. the user notes on the php manual hex2dec page does bring up the subject of converting colours though.cheers Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 19, 2007 Share Posted January 19, 2007 [quote author=redbullmarky link=topic=123189.msg508862#msg508862 date=1169247668][url=http://uk2.php.net/hex2dec]hex2dec[/url] should set you on your way ;)you'll just have to note that each pair in the 6 character hex string amounts to a number, so you will (as far as i know, unless there's another specific function) have to split it up first into 3 parts and then perform the hex2dec conversions.cheers[/quote]In fact, most of the comments on that page deal with this topic. Quote Link to comment Share on other sites More sharing options...
michaellunsford Posted January 19, 2007 Author Share Posted January 19, 2007 Thanks for the quick replies. I checked the manual and did a google search -- but I didn't know the right language.bin2hex looks like the magic. Thanks! Quote Link to comment Share on other sites More sharing options...
redbullmarky Posted January 19, 2007 Share Posted January 19, 2007 [quote author=michaellunsford link=topic=123189.msg508870#msg508870 date=1169248324]Thanks for the quick replies. I checked the manual and did a google search -- but I didn't know the right language.bin2hex looks like the magic. Thanks![/quote]you mean hex2dec? ;) Quote Link to comment Share on other sites More sharing options...
michaellunsford Posted January 19, 2007 Author Share Posted January 19, 2007 great, more brain cells gone. I need a nap ;) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.