2023-03-25 php truncateTextByWords(string $string, int $maxWords = 10): string return preg_replace(‘/((\w+\W*){‘ . ($maxWords – 1) . ‘}(\w+))(.*)/’, ‘${1}’, $string) ab