TextFit

TextFit is a simple PHP class that shortens a string, or fits an array of plain text strings into columns somewhat like an HTML table. This is most useful when using a fixed-width font, for example in a plain text email.

Here's an example of what the class might produce:


Name              | Age | Country      |     Amount
===================================================
Nguyen Thi Anh    | 40  | Vietnam      |   2,108.50
S. Baldrick       | 36  | England      |      14.75
Michael Bruce     | 28  | Australia    |     648.15
Buck Gregson      | 48  | USA          |   4,444.44
---------------------------------------------------

The width and alignment can be set for each column, and for text that's too wide to fit its column, you have the choice of shortening it to fit into one line, or wrapping within the column.

Example of text shortening:

Name              | Interests               | Username
-----------------------------------------------------------
Nguyen Thi Anh    | walking, hockey,...     | anh17
S. Baldrick       | turnips, cooking,...    | balders
Michael Bruce     | beer, sport,...         | 85commodore
Buck Gregson      | beer, driving           | carersharer
-----------------------------------------------------------

Example of text wrapping:

Name              | Interests               | Username
-----------------------------------------------------------
Nguyen Thi Anh    | walking, hockey,        | anh17
                  | philately, football     |
                  |                         |
S. Baldrick       | turnips, cooking,       | balders
                  | cleaning                |
                  |                         |
Michael Bruce     | beer, sport, barbecues, | 85commodore
                  | football, ethnic        |
                  | stereotyping,           |
                  | butterflies             |
                  |                         |
Buck Gregson      | beer, driving           | carersharer
                  |                         |
-----------------------------------------------------------

TextFit is free software, released under the GNU GPL.

TextFit
Version:

1.1.3

Licence:

GNU GPL

Requires:

PHP5+

Filename:

TextFit-v1.1.3.zip

File date: 

2012-12-05


Write a comment

  • Required fields are marked with *.