How to convert a multidimensional array to an one-dimensional array format that supports curl submission
This article introduces the knowledge of "how to convert a multidimensional array into an one-dimensional array format that supports curl submission". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
The copy code is as follows:
/ * *
* @ desc multidimensional array converted to support curl submission array
* @ 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
}
That's all for "how to convert a multidimensional array to an one-dimensional array format that supports curl submission". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!