$_SERVER['QUERY_STRING']的字符串類似:a=1&b=2&c=3&vardate=2012-11-12希望能轉(zhuǎn)換成$_GET數(shù)組,內(nèi)容類似于:$_GET['a']=1;$_GET['b']=2;
$_GET['c']=3;$_GET['vardate']='2012-11-12';我的思路是把原始字符串根據(jù)&切分后,再根據(jù)=切分。list(,$tmp) = explode("?", $_SERVER['QUERY_STRING']);$a = explode("&",$tmp);foreach($a as $v) { $b = explode("=", $v); $_GET[$b[0]] = $b[1];
}var_dump($_GET);
不考慮數(shù)值類型的話,該怎么實(shí)現(xiàn)? 求一個(gè)比較優(yōu)雅的代碼!
月關(guān)寶盒
2023-04-16 17:13:50