shortText function toggler in php

I often have to show a shortened version of a news item and then a link to show the entire news article or whatever. Here’s a way to get that short text! [code lang=”php”] function shortText($text, $length) { if( strlen($text) > $length ) return substr(preg_replace(“/(]*>)/”, “”, $text), 0, $length).”…”; return Read more…

By Andrew Odendaal, ago