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
Not enough user ratingsTotal: 424 All time: 6,352 This week: 147Up
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: United States United States
Age: ???
All time rank: 993138 in United States United States
Week rank: 264 Up20 in United States United States 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,352
This week:147Up
User Comments (1)