私はテキストをスラグ化する機能を持っていますが、 ":"を "/"に置き換える必要があることを除いてはうまくいきます。現在、それはすべての非文字または数字を " - "で置き換えます。ここにあります:slugify関数の ":"を "/"に置き換えるにはどうしたらいいですか?
function slugify($text)
{
// replace non letter or digits by -
$text = preg_replace('~[^\\pL\d]+~u', '-', $text);
// trim
$text = trim($text, '-');
// transliterate
if (function_exists('iconv'))
{
$text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);
}
// lowercase
$text = strtolower($text);
// remove unwanted characters
$text = preg_replace('~[^-\w]+~', '', $text);
if (empty($text))
{
return 'n-a';
}
return $text;
}
質問は何ですか? – zerkms