/ Published in: PHP
Esta función sólo trunca una cadena cuando encuentra el punto de ruptura que le indiquemos -un espacio, un punto, dos puntos,..- y resulta muy útil, por ejemplo, para mostrar un extracto de un artículo completo sin romper las palabras.
Expand |
Embed | Plain Text
// Original PHP code by Chirp Internet: www.chirp.com.au // Please acknowledge use of this code by including this header. function myTruncate($string, $limit, $break=“.”, $pad=“…”) { // return with no change if string is shorter than $limit return $string; // is $break present between $limit and the end of the string? } } return $string; }
You need to login to post a comment.
