function trimlink($text, $length) { $dec = array("&", "\"", "'", "\\", '\"', "\'", "<", ">"); $enc = array("&", """, "'", "\", """, "'", "<", ">"); $text = str_replace($enc, $dec, $text); if (strlen($text) > $length) $text = substr($text, 0, ($length-3))."..."; $text = str_replace($dec, $enc, $text); return $text; }