PHP Classes

Text Fit: Shorten text to fit within a limited length

Recommend this page to a friend!
  Info   Screenshots Screenshots   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 47%Total: 425 All time: 6,357 This week: 673Up
Version License PHP version Categories
text-fit 1.1.3GNU General Publi...5.0PHP 5, Text processing


This class can shorten text to fit within a limited length.

It can shorten a given text string by truncating text that exceeds a given length.

The class can also shorten file names by limiting them to a given length but preserving the original file name extension.

It may also fit text into columns of table cells by either shortening or wrapping the text in the column.

Innovation Award
PHP Programming Innovation award nominee
December 2012
Number 3

Prize: One downloadable copy of PhpED Professional
Sometimes it is necessary to limit the length of text to be displayed in certain circumstances. That is the case of text in e-mail messages or file names.

This class provides a solution to truncate text in a way that it does not cut words in the middle.

It can also shorten file names in a way that they do not exceed a certain limit, but still keep the file extension at the end of the file name.

Manuel Lemos
Picture of Tony
Name: Tony <contact>
Classes: 6 packages by
Country: Australia Australia
Age: ???
All time rank: 99017 in Australia Australia
Week rank: 286 Up5 in Australia Australia Up
Innovation award
Innovation award
Nominee: 2x

  • TextFit-examples.png
  Files folder image Files  
File Role Description
Plain text file TextFit.class.php Class TextFit class
Accessible without login Plain text file examples.php Example Example script
Accessible without login Plain text file TextFit.doc.txt Doc. Usage information
Accessible without login Plain text file GPL.txt Lic. License information

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:6,357
This week:673Up
User Ratings User Comments (1)
 All time