Mega Code Archive
Shorten a text string
* where $text is the text you want to shorten.
* * Example * Test it using this in a PHP page:
*
*/
function ShortenText($text)
{
// Change to the number of characters you want to display
$chars = 25; $text = $text." ";
$text = substr($text,0,$chars);
$text = substr($text,0,strrpos($text,' '));
$text = $text."..."; return $text;
}
?>