<?PHP$url= ' Http://www.baidu.com/index.php?m=content&c=index&a=lists&catid=6&area=0&author=0&h=0 ®ion=0&s=1&page=1 ';$arr=Parse_url($url);Var_dump($arr);$arr _query= Converturlquery ($arr[' Query ']);Var_dump($arr _query);Var_dump(Geturlquery ($arr _query));/** * Change string parameter to array * @param $query * @return array Array (size=10) ' m ' = = String ' content ' (length=7) ' c ' = = String ' index ' (length=5) ' a ' = ' + string ' lists ' (length=5) ' catid ' = = String ' 6 ' (lengt h=1) ' area ' = = String ' 0 ' (length=1) ' Author ' = = String ' 0 ' (length=1) ' h ' = = String ' 0 ' (length=1) ' region ' = = String ' 0 ' (length=1) ' s ' = = String ' 1 ' (length=1) ' Page ' = String ' 1 ' (length=1)*/functionConverturlquery ($query){ $queryParts=Explode(' & ',$query); $params=Array(); foreach($queryParts as $param) { $item=Explode(' = ',$param); $params[$item[0]] =$item[1]; } return $params;}/** * Change parameter to String * @param $array _query * @return String ' m=content&c=index&a=lists&catid=6&area=0 &author=0&h=0®ion=0&s=1&page=1 ' (length=73)*/functionGeturlquery ($array _query){ $tmp=Array(); foreach($array _query as $k=$param) { $tmp[] =$k.‘ = '.$param; } $params=implode(' & ',$tmp); return $params;}
Https://www.jb51.net/article/73900.htm
PHP parses the URL and obtains the parameters in the URL and gets the URL parameters