$arr = array('key1'=>'val1','key2'=>'val2');
$str = '';
foreach($arr as $k=>$v)
{
$str .= '&' . $k . '=' . urlencode($v);
}
echo substr($str,1);
或者
$arr = array('key1'=>'val1','key2'=>'val2');
$str = '';
foreach($arr as $k=>$v)
{
$str .= '&' . urlencode($k) . '=' . urlencode($v);
}
echo substr($str,1);
$k
是否需要进行urlencoded?
答案 0 :(得分:4)
是; 如果您使用PHP5,我猜猜http_build_query就是您所需要的;)