TextCropper
Table of Contents
Methods
- crop() : string
- Implements "cropHTML" which is a modified "substr" function allowing to limit a string length to a certain number of chars (from either start or end of string) and having a pre/postfix applied if the string really was cropped.
Methods
crop()
Implements "cropHTML" which is a modified "substr" function allowing to limit a string length to a certain number of chars (from either start or end of string) and having a pre/postfix applied if the string really was cropped.
public
crop(string $content, int $numberOfChars, string $replacementForEllipsis, bool $cropToSpace) : string
Note: Crop is done without properly respecting html tags and entities.
Parameters
- $content : string
-
The string to perform the operation on
- $numberOfChars : int
-
Max number of chars of the string. Negative value means cropping from end of string.
- $replacementForEllipsis : string
-
The pre/postfix string to apply if cropping occurs.
- $cropToSpace : bool
-
If true then crop will be applied at nearest space.
Return values
string —The processed input value.