...

View Full Version : read a file - comma separate and output to screen



jarv
10-14-2009, 04:49 PM
hi,

Can someone please help?
I need a bit of PHP code that reads data in a file and comma separates it and outputs it to the screen?!

here is what i have written so far:


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

?>

this 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

mlseim
10-14-2009, 05:48 PM
<?PHP

$file_handle = fopen("colors/rgb.csv", "r");

while (!feof($file_handle) ) {

$line_of_text = fgetcsv($file_handle, 1024);

// Convert DEC to HEX.
$val1=dechex($line_of_text[2]);
$val2=dechex($line_of_text[3]);
$val3=dechex($line_of_text[4]);

print $val1 . $val2 . $val3 . "<BR>";

}

fclose($file_handle);

?>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum