Skip to content

Instantly share code, notes, and snippets.

@k1ic
Created January 30, 2015 06:01
Show Gist options
  • Save k1ic/5412eef39de2f2b9b144 to your computer and use it in GitHub Desktop.
Save k1ic/5412eef39de2f2b9b144 to your computer and use it in GitHub Desktop.
将query_string转为数组
/**
* 将查询字符串解析为数组
* @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