获取无page参数的url

	//$url= ‘http://zhidao.baidu.com/question/469321857.html?push=core&group=1‘;
	//$url = $_SERVER[‘REQUEST_URI‘].(strpos($_SERVER[‘REQUEST_URI‘],‘?‘)? ‘‘ : "?");
	
	$parse = parse_url(‘question/469321857.html?push=core&group=1&page=121‘);
	//Array ( [path] => question/469321857.html [query] => push=core&group=1&page=121 ) 
	print_r($parse);
	if(isset($parse[‘query‘])){
		parse_str($parse[‘query‘],$params);
		/*
		Array
		(
			[push] => core
			[group] => 1
			[page] => 121
		)
		*/
		unset($params[‘page‘]);
		/*
		Array
		(
			[push] => core
			[group] => 1
		)
		*/
		$url = $parse[‘path‘].‘?‘.http_build_query($params);
		//question/469321857.html?push=core&group=1
	}

 

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。