Jump to content

Recommended Posts

<?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

Link to comment
https://forums.phpfreaks.com/topic/177669-converting-rgb-values-to-hex/
Share on other sites

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.