character_limiter()

character_limiter($str[, $n = 500[, $end_char = '…']])

Parameters:
  • $str (string) – Input string
  • $n (int) – Number of characters
  • $end_char (string) – End character (usually an ellipsis)
Returns:

Character-limited string

Return type:

string

Truncates a string to the number of characters specified. It maintains the integrity of words so the character count may be slightly more or less than what you specify.

Example:

$string = "Here is a nice text string consisting of eleven words.";
$string = character_limiter($string, 20);
// Returns:  Here is a nice text string

The third parameter is an optional suffix added to the string, if undeclared this helper uses an ellipsis.

Note

If you need to truncate to an exact number of characters please see the ellipsize() function below.

doc_CodeIgniter
2016-10-15 16:30:54
Comments
Leave a Comment

Please login to continue.