Created
January 30, 2015 06:01
-
-
Save k1ic/5412eef39de2f2b9b144 to your computer and use it in GitHub Desktop.
将query_string转为数组
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 将查询字符串解析为数组 | |
* @param string | |
* @return array | |
*/ | |
private static function _parseQueryString($query = '') | |
{ | |
$res = array(); | |
$pieces = explode('&', trim($query)); | |
foreach ($pieces as $piece) // $piece likes 'serial=123' | |
{ | |
$kv = explode('=', $piece); | |
if (count($kv) != 2 || $kv[0] == '') | |
{ | |
continue; | |
} | |
$res[$kv[0]] = $kv[1]; | |
} | |
return $res; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment