AHAH
Arch
Bilder
Blog
Bookmarking
CCK
ClamAV
CSS
DD-WRT
Debian
Downloads
Drucken
Drucker
Drupal
Drupaltipp
DSL
EASYS
Feed
Firefox
Flash
Flickr
FreeBSD
Frugalware
Git
LAN
Linux
Maps
Mepis
MyQL
O2
RSS
Service
SLAX
Taxonomie
Telefon
Template
Thunar
Thunderbird
TinyMCE
Tools
Ubercart
Ubuntu
Umwelt
VectorLinux
Views
Vista
Webdesign
WLAN
XFCE
ZenWalk
Help function for truncating text strings.
02.03.09 - quiptime
Objective
Create one function that controls the length for one string of characters in drupal.
Function
/*
* Help function for truncating text strings.
*
* @param $string
* The string to truncate.
* @param $length
* The lenght for truncate.
* @param $replacement
* The replacement at the end of the string.
* @return
* The truncated string.
*/
function max_length($string, $length = 50, $replacement = '...') {
if (!is_string($string)) {
return '';
}
$string = check_plain($string);
if (drupal_strlen($string) > $length) {
$output = substr($string, 0, $length) . $replacement;
}
else {
$output = $string;
}
return $output;
}
- Blog von quiptime
- Anmelden um Kommentare zu schreiben
- Druckversion