Trim string to certain length and insert ellipses
Copy this code and paste it in your HTML
// Trims a string down to a certain length and inserts an ellipses if it was trimmed.
function cut($str, $len=30) {
return substr($str, 0, $len-2) . '…'; } else {
return $str;
}
}
Report this snippet
Comments
Subscribe to comments