ellipsize($str, $max_length[, $position = 1[, $ellipsis = '…']])
Parameters: |
|
---|---|
Returns: |
Ellipsized string |
Return type: |
string |
This function will strip tags from a string, split it at a defined maximum length, and insert an ellipsis.
The first parameter is the string to ellipsize, the second is the number of characters in the final string. The third parameter is where in the string the ellipsis should appear from 0 - 1, left to right. For example. a value of 1 will place the ellipsis at the right of the string, .5 in the middle, and 0 at the left.
An optional forth parameter is the kind of ellipsis. By default, … will be inserted.
Example:
$str = 'this_string_is_entirely_too_long_and_might_break_my_design.jpg'; echo ellipsize($str, 32, .5);
Produces:
this_string_is_e…ak_my_design.jpg
Please login to continue.