Looking for somewhere to host your site? Browse our PHP web hosts section!

Home > Code Snippets > Shorten a text string

Help us grow - Submit your code!

Shorten a text string

Submitted by Totally PHP, 9th February 2004

Description

Function to shorten / truncate a string of text into a specific number of characters and add three dots (...) to the end. This will also round the text to the nearest whole word instead of cutting off part way through a word.

The code

There was a problem whilst attempting to load the source code.

Get the code

Download the file to your computer: Click here to get the file