Skip to content

String Helpers

Toolbelt provides a wide number of Twig filters and functions for manipulating strings.

Wrapped PHP Functions

The following functions/filters are wrappers for PHP native functions:

Twig nameAvailable in Twig asWrapped function / signatureDocs
parse_urlfunctionparse_url(string $url, int $component = -1): int|string|array|null|false🔗
dirnamefunctiondirname(string $path, int $levels = 1): string🔗
pathinfofunctionpathinfo(string $path, int $flags = PATHINFO_ALL): array|string🔗
md5function, filtermd5(string $string, bool $binary = false)🔗

Wrapped craft\helpers\StringHelper Functions

The following functions/filters are wrappers for functions in Craft's craft\helpers\StringHelper class:

Twig nameAvailable in Twig asWrapped method / signatureDocs
UUIDfunctionUUID(): string🔗
basenamefunction, filterbasename(string $path, string $suffix = ''): string🔗
humanizefunction, filterhumanize(string $str): string🔗
slugifyfunction, filterslugify(string $str, string $replacement = '-', ?string $language = null): string🔗
titleizefunction, filtertitleize(string $str, ?[] $ignore = null): string🔗
titleizeForHumansfunction, filtertitleizeForHumans(string $str, ?[] $ignore = null): string🔗

Extra String Helpers

The following functions/filters are custom to Toolbelt:

Twig nameAvailable in Twig asSignatureDocs
stringify(), s()function, filterstringify(string $str): \Stringy\StringyConverts a string to a Stringy instance