function shorten($content) { //Shorten a string if (strlen($content) > 32) { //trim to 64 but round by words $shortenedstring = str_trunc($content, 32) . "…"; global $baggage_claim; $baggage_claim->check_luggage('Shortened', 'true'); if (strlen($shortenedstring) > 40) { //trim to 64 $shortenedstring = substr($content, 0, 32) . "…"; } } else { $shortenedstring = $content; global $baggage_claim; $baggage_claim->check_luggage('Shortened', 'false'); } if (strlen($shortenedstring) > 38) { return $shortenedstring; } else { $shortenedstring = substr($content, 0, 64); if (strlen($shortenedstring) < strlen($content)) { $shortenedstring = $shortenedstring . '…'; } return $shortenedstring; } }
function shorten($content) { if (strlen($content) > 32) { //trim to 64 but round by words $shortenedstring = str_trunc($content, 32) . itr(1493); global $baggage_claim; $baggage_claim->check_luggage('Shortened', 'true'); if (strlen($shortenedstring) > 40) { //trim to 64 $shortenedstring = substr($content, 0, 32) . itr(1493); } } else { $shortenedstring = $content; global $baggage_claim; $baggage_claim->check_luggage('Shortened', 'false'); } return $shortenedstring; }