我正在尝试生成一些html页面,我有:
$category="Category Name";
$zone="Zone Name";
我想获得$page="category-name-in-zone-name.html"
答案 0 :(得分:2)
您正在寻找' slug创建的概念':
function makeSlug($input)
{
$interim = iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $input);
$interim = preg_replace("/[\"']+/i", '', $interim);
$interim = preg_replace("/[^a-z0-9\\d]+/i", '-', $interim);
return trim(strtolower($interim), ' -');
}
echo makeSlug("$category in $zone").'.html';