PHP獲取地址url引數值
阿新 • • 發佈:2019-02-15
$url = 'http://apps.ebrun.com/dmp_api/get_keyword_report.php?k=進口電商&p=北京&c=東城&st=2017-04-01&et=2017-04-30'; $arr = parse_url($url); $arr_query = convertUrlQuery($arr['query']); var_dump($arr_query); var_dump(getUrlQuery($arr_query));die; function convertUrlQuery($query) { $queryParts = explode('&', $query); $params = array(); foreach ($queryParts as $param) { $item = explode('=', $param); $params[$item[0]] = $item[1]; } return $params; } function getUrlQuery($array_query) { $tmp = array(); foreach($array_query as $k=>$param) { $tmp[] = $k.'='.$param; } $params = implode('&',$tmp); return $params; }