http_build_query
(PHP 5) http_build_query — 生成 URL-encode 之后的请求字符串
<?php
$data = array('foo'=>'bar',
'baz'=>'boom',
'cow'=>'milk',
'php'=>'hypertext processor');
echo http_build_query($data); // foo=bar&baz=boom&cow=milk&php=hypertext+processor?>
compact
array compact ( mixed
$varname
[, mixed $...
] )(PHP 4, PHP 5) compact — 建立一个数组,包括变量名和它们的值
<?php
$city = "San Francisco";
$state = "CA";
$event = "SIGGRAPH";
$result = compact("city
", "state
", "event
");
// array('city'=>'"San Francisco"
','state
'=>'CA
','event' => "SIGGRAPH")
?>
-------------
$qs=compact('province','city','name'); foreach($qs as $key => $value){ if(!$value){ unset($qs[$key]); } } $url='something/search/?'.http_build_query($qs) ;