word_limiter()

word_limiter($str[, $limit = 100[, $end_char = '…']])

Parameters:
  • $str (string) – Input string
  • $limit (int) – Limit
  • $end_char (string) – End character (usually an ellipsis)
Returns:

Word-limited string

Return type:

string

Truncates a string to the number of words specified. Example:

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

The third parameter is an optional suffix added to the string. By default it adds an ellipsis.

doc_CodeIgniter
2016-10-15 16:32:47
Comments
Leave a Comment

Please login to continue.