How to format CLI tabular data?

From: Date: Mon, 08 Oct 2007 22:59:46 +0000
Subject: How to format CLI tabular data?
Groups: php.general 
Request: Send a blank email to php-general+get-262941@lists.php.net to get a copy of this message
I write many CLI scripts in PHP to clean up DB records, etc via crontab scripts. Often though, I implement command line switches to 'debug' or see various data as a precaution before actually purging. Perl has some neat tools built in to format tabular data: http://www.usenix.org/publications/perl/perl08.html Does PHP have any tools like this? I'd prefer not to pull in some PEAR package or other bloat, but I'll take what I can get if it actually works well. I was hoping there are some tips/tricks to show simple tabular data: i.e.: # foo.php --showgroups ================================== Groups ================================== Name: Expires: Date: -------- ------------ ----------- groupA 3 hours 2007-10-08 groupBeta 10 hours 2007-11-10 groupC 1 week 2007-12-31 notice basic things like alignment, length of data (as in 'tabs' won't work), etc.

« previous php.general (#262941) next »