PHP获取地址url参数值

$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;
}

你可能感兴趣的:(PHP)