url_title()

function url_title(string $value, bool $transliteration = true): string

Description

Converts a string into a URL-friendly slug format. If the intl extension is loaded and transliteration is enabled, international characters are converted to their ASCII equivalents. Non-alphanumeric characters are replaced with dashes, which are trimmed from the start and end, and the result is lowercased.

Parameters

Parameter Type Description Default
$value string The string to be converted into a slug. N/A
$transliteration bool Whether to transliterate international characters to ASCII using the intl extension. true

Return Value

Type Description
string The slugified version of the input string.

Example Usage

PHP
echo url_title('Hello World!');
// "hello-world"

echo url_title('Café Menu', true);
// "cafe-menu" (with intl extension)