|All requests||>||Read tab delimited text file and sort...||>||Request new recommendation||>||Featured requests||>||No recommendations|
by Michael Wassil - 6 years ago (2015-02-10)
I need to read a tab delimited text file, display it as a table sorted by columns
The read() method in my class will read a tab/comma delimited file into a matrix, doesn't have a built in sorting feature, though. The method defaults to csv, but if you change the $_csvdelim_ variable, or include the customer delimiter as the third parameter, you can read any type of delimited file. So for example, you would need these three lines:
include "DB.php"; $db = new DB(); print_r($db->read("delimited.txt", "csv", "\t"));
The second parameter must be "csv" so the method knows it's dealing with delimited text.
Hope that helps.