2010-01-24 68 views
0
$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需要進行url編碼?

回答