- 相關(guān)推薦
php字符轉(zhuǎn)URL地址的函數(shù)
php字符應(yīng)該如何轉(zhuǎn)成URL地址呢,下面小編為大家?guī)砹岁P(guān)于php字符轉(zhuǎn)URL地址的函數(shù),歡迎大家閱讀!
php字符轉(zhuǎn)URL地址的函數(shù)
英文
代碼如下
function tourl($str) {
$str = preg_replace('/[^a-zA-Z0-9]+/', '-', $str);
$str = trim($str, '-');
return strtolower($str);
}
包含特殊字符
代碼如下
function strtourl($str) {
$str = htmlentities($str, ENT_QUOTES, "UTF-8");
$str = preg_replace('/&([a-z]{1,2})(?:acute|lig|grave|ring|tilde|uml|cedil|caron);/i','1',$str);
$str = html_entity_decode($str, ENT_QUOTES, "UTF-8");
$str = preg_replace('/[^a-z0-9]+/i', '-', $str);
return strtolower($str);
}
【php字符轉(zhuǎn)URL地址的函數(shù)】相關(guān)文章:
php常用的url處理函數(shù)集10-15
php字符串截取函數(shù)06-10
php的字符串常用函數(shù)06-15
PHP字符串函數(shù)大匯總05-25
PHP字符串操作09-29
php實現(xiàn)utf-8轉(zhuǎn)unicode函數(shù)分享09-17
PHP簡單的偽靜態(tài)URL機制實現(xiàn)09-02
PHP字符集如何轉(zhuǎn)換07-13
php字符串截取問題05-02