johnsliced Posted October 14, 2009 Share Posted October 14, 2009 <?PHP $file_handle = fopen("colors/rgb.csv", "r"); while (!feof($file_handle) ) { $line_of_text = fgetcsv($file_handle, 1024); print $line_of_text[2] . $line_of_text[3] . $line_of_text[4] . "<BR>"; } fclose($file_handle); ?> my code above currently outputs a list of RGB numbers for example: Ref_RRef_GRef_B 149119109 190171158 200161148 154109111 1088888 1408579 I would like to now convert these numbers (each line) to HEX colors please help?! thanks Quote Link to comment https://forums.phpfreaks.com/topic/177669-converting-rgb-values-to-hex/ Share on other sites More sharing options...
Daniel0 Posted October 14, 2009 Share Posted October 14, 2009 Split it up and use dechex. By the way, you've chosen a really bad format for storing it in. Take for instance this: 11211222. It could be either 11,211,222 or 112,11,222 or 112,112,22. Edit: Ah, never mind. I didn't notice that it was just the way you were outputting it. In that case, just call dechex() on all of them. Quote Link to comment https://forums.phpfreaks.com/topic/177669-converting-rgb-values-to-hex/#findComment-936812 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.