public static slug ( string $string, string $replacement = '-', boolean $lowercase = true ) : string | ||
$string | string | An arbitrary string to convert |
$replacement | string | The replacement to use for spaces |
$lowercase | boolean | whether to return the string in lowercase or not. Defaults to `true`. |
return | string | The converted string. |
public static function slug($string, $replacement = '-', $lowercase = true)
{
$string = static::transliterate($string);
$string = preg_replace('/[^a-zA-Z0-9=\\s—–-]+/u', '', $string);
$string = preg_replace('/[=\\s—–-]+/u', $replacement, $string);
$string = trim($string, $replacement);
return $lowercase ? strtolower($string) : $string;
}