PHP 去除url参数中出现+、空格、=、%、&、#等字符的解决办法, PHP去除影响url路径的字符

/*
 * 去除url参数中出现+、空格、=、%、&、#等字符的解决办法
 * */
function get_url_str($title){
    if($title){
        $zifu = array(
            0 => '+',
            1 => '/',
            2 => '?',
            3 => '?',
            4 => '%',
            5 => '#',
            6 => '&',
            7 => '=',
        );
        $s_title = $title;
        foreach ($zifu as $k=>$r) {
            $s_title = str_replace($r,'-',$s_title);
        }
        //dump($s_title);die();
        return $s_title;
    }
}

 

posted @ 2019-07-26 09:55  遇事稳坐钓鱼台  阅读(2917)  评论(0编辑  收藏  举报