Revision: 11264
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at January 29, 2009 13:16 by sveggiani
Initial Code
/**
* If a string is too long, shorten it in the middle
* @param string $text
* @param int $limit
* @return string
*/
function shorten($text, $limit = 25) {
if (strlen($text) > $limit) {
$pre = substr($text, 0, ($limit / 2));
$suf = substr($text, -($limit / 2));
$text = $pre .' ... '. $suf;
}
return $text;
}
Initial URL
http://www.milesj.me/blog/read/15/5-custom-basic-php-string-functions
Initial Description
Took from http://www.milesj.me/blog/read/15/5-custom-basic-php-string-functions
Initial Title
shorten a string
Initial Tags
Initial Language
PHP