![]() |
Documentación GVHIDRA 3.1.5
|
Ir al código fuente de este archivo.
Namespaces | |
namespace | Smarty |
Funciones | |
smarty_modifier_truncate ($string, $length=80, $etc= '...', $break_words=false, $middle=false) |
smarty_modifier_truncate | ( | $ | string, |
$ | length = 80 , |
||
$ | etc = '...' , |
||
$ | break_words = false , |
||
$ | middle = false |
||
) |
Smarty truncate modifier plugin
Type: modifier
Name: truncate
Purpose: Truncate a string to a certain length if necessary, optionally splitting in the middle of a word, and appending the $etc string or inserting $etc into the middle. truncate (Smarty online manual) Monte Ohrt
string | |
integer | |
string | |
boolean | |
boolean |
Definición en la línea 27 del archivo modifier.truncate.php.
{ if ($length == 0) return ''; if (strlen($string) > $length) { $length -= strlen($etc); if (!$break_words && !$middle) { $string = preg_replace('/\s+?(\S+)?$/', '', substr($string, 0, $length+1)); } if(!$middle) { return substr($string, 0, $length).$etc; } else { return substr($string, 0, $length/2) . $etc . substr($string, -$length/2); } } else { return $string; } }