/ 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.
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
Copy this code and paste it in your HTML
// 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; }
Comments
