Destramic Posted January 30, 2015 Share Posted January 30, 2015 first of all...its good to see the site back . my question guys is i'm wondering is there a way of getting the column number when reading a .cvs file? ie. a, b, c, d, aa, ab etc? $row = 1; if (($handle = fopen($file, "r")) !== FALSE) { while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $num = count($data); echo "<p> $num fields in line $row: <br /></p>\n"; $row++; for ($c=0; $c < $num; $c++) { //echo $data[$c] . "<br />\n"; } } fclose($handle); } now $num counts the columns...but i want to convert that into a alphabetical column...is there a easy solution? thanks guys Quote Link to comment Share on other sites More sharing options...
Solution CroNiX Posted January 30, 2015 Solution Share Posted January 30, 2015 (edited) Something like this: https://www.daniweb.com/web-development/php/threads/364699/php-converting-numbers-to-letters or http://www.tiny-threads.com/blog/2013/11/12/php-convert-number-excel-column-letter-2/ Edited January 30, 2015 by CroNiX 1 Quote Link to comment Share on other sites More sharing options...
Barand Posted January 30, 2015 Share Posted January 30, 2015 for ($c=0, $a='a'; $c < $num; $c++, $a++) { //echo "($a) " . $data[$c] . "<br />\n"; } Quote Link to comment Share on other sites More sharing options...
Destramic Posted January 31, 2015 Author Share Posted January 31, 2015 thanks for your posts guys...cronix that was just what i was after ...cheers 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.