Wednesday, January 12, 2011

truncate_utf8() is used as a substring function in drupal

In Drupal 4.7 – 6
truncate_utf8($string, $len, $wordsafe = FALSE, $dots = FALSE)

In Drupal 7
truncate_utf8($string, $max_length, $wordsafe = FALSE, $add_ellipsis = FALSE,$min_wordsafe_length = 1)


Truncate a UTF-8-encoded string safely to a number of characters.
Parameters

$string The string to truncate.

$len An upper limit on the returned string length.

$wordsafe Flag to truncate at last space within the upper limit. Defaults to FALSE.

$dots Flag to add trailing dots. Defaults to FALSE.
Return value

The truncated string

No comments:

Post a Comment