Tony Landis
Personal website of Tony Landis

31 Oct 08 PHP Array to Text Tables

I needed this for a little project so I coded it up. I haven’t done a lot of tests but it works just fine for formatting the associative arrays I have run through it.

The class supports multi-line rows, limiting the width of the column, and automatically creating a heading based on the keys from the associative array.

Usage and Output Example

Text Table Formatted Output of above example:

| COMPANY  | ID |       BALANCE       |
| AIG      | 1  | -$99,999,999,999.00 |
| Wachovia | 2  | -$10,000,000.00     |
| HP       | 3  | $555,000.000.00     |
| IBM      | 4  | $12,000.00          |

Full class source code after the jump…

Tags: , ,

02 Nov 07 Groovy Http POST/GET Class

I was working on a project in and needed to do POST as well as read the response headers.

I was unable to find a suitable class or method for this in either Groovy or Java, so I wrote this class. It opens a socket to the requested host, and writes to the socket using getOutputStream() and PrintWriter(). It reads the response from the server using DataInputStream() and getInputStream().


Tags: , , ,