如:$res = utf-8=3&wek=123&id=5&toes=0998887&des_id=78798799
解决方案:
/**
* queryStrToArray
* http参数转数组
* @param mixed $queryStr
* @access private
* @return void
*/
private function queryStrToArray($queryStr)
{
$resultArray = array();
foreach (explode('&', $queryStr) as $pair) {
list($key, $value) = explode('=', $pair);
//a dot present
if (strpos($key, '.') !== false) {
list($subKey, $subVal) = explode('.', $key);
if (preg_match('/(?P<name>\w+)\[(?P<index>\w+)\]/', $subKey, $matches)) {
$resultArray[$matches['name']][$matches['index']][$subVal] = $value;
} else {
$resultArray[$subKey][$subVal] = $value;
}
} else {
$resultArray[$key] = $value;
}
}
return $resultArray;
}
$resultArr = $this->queryStrToArray($res);