but PHP is so much fun!
I would like to know how to trim the variable to display only the first 200 characters of description?
thanks a lot guys!
Moderator: General Moderators
Code: Select all
<?PHP
function truncate_string($details,$max)
{
if(strlen($details)>$max)
{
$details = substr($details,0,$max);
$i = strrpos($details," ");
$details = substr($details,0,$i);
$details = $details." ..... ";
}
return $details;
}
$text = truncate_string("hello there. This is a long string",19);
?>