復制代碼 代碼如下:
/**
* @desc 多維數組轉化為支持curl提交數組
* @author 2013-07-8
*/
public function toPost(array $params = array(), $pre = '')
{
$result = array();
foreach ($params as $key => $val)
{
if (is_array($val))
{
$subPre = ($pre=="") ? $key : $pre . "[" . $key . "]";
//$pre = "[" . $key . "]";
$result = array_merge($result, toPost($val, $subPre));
}
else
{
$result[$pre."[".$key."]"] = $val;
}
}
return $result;
}