Forum Moderators: coopster
[webmasterworld.com...]
function truncate($string, $length = '', $replacement = '...', $start = 180)
{
if (strlen($string) <= $start)
return $string;
if ($length)
{
return substr_replace($string, $replacement, $start, $length);
}
else
{
return substr_replace($string, $replacement, $start);
}
}
I don't understand the if($length) part. $length is equal to a space so if($length) will always be true. In that case, the else part would never be executed. Someone please explain. Thank you!