string cut(string string, int width [, string padding]) -- Truncate a string.
<?php |
This will output:
This is a lo... |
Published under the terms of the BSD License
<?php
function cut($string, $width, $padding = "...") {
return (strlen($string) > $width ? substr($string, 0, $width-strlen($padding)).$padding : $string);
}
?>
Last updated: Sat Jun 14 20:02:45 CEST 2008