Are there any libraries I can use to pretty print tabular data(from php code)?
What I mean is, if I have:
$headers = array("name", "surname", "email");
$data[0] = array("bill", "gates", "bill@microsoft.com");
$data[1] = array("steve", "jobs", "steve@apple.com");
/*...*/
pretty_print($headers, $data);
It will print my data neatly(preferably using tableless html code & css)?
Why not just write your own?
I wrote an example below. Note that I haven’t tested this – it’s the definition of “air code” so beware. Also, you could add checks to make sure
count($rows) > 0or to make surecount($rows) == count($headers)or whatever..The point is just that it isn’t that hard to throw something together:
As a final note, why would you want to use HTML/CSS layouts rather than tables for this? Tables are for tabular data which this obviously is. This is their purpose!
The trend against using tables is for using them to layout pages. They’re still quite valid for tabular data, and will be for the foreseeable future.