Back to PhocacartUtils class

Method wordDeleteWhole

public static
wordDeleteWhole
(mixed $string, mixed $length, mixed $end = '...')

Method wordDeleteWhole - Source code

public static function wordDeleteWhole($string, $length, $end = '...')
{
    if (strlen($string) < $length || strlen($string) == $length) {
        return $string;
    } else {
        preg_match('/(.{' . $length . '}.*?)\\b/', $string, $matches);
        return rtrim($matches[1]) . $end;
    }
}