Get the App
SLTechnology News&Howtos  ›  Development  › 

How to convert a multidimensional array to an one-dimensional array format that supports curl submission

Shulou Source: shulou.com Published: 2022-06-03 06:56:23 09月30日 Update

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!

Tags: Array multidimensional support format one-dimensional code content more knowledge practicality learning next dilemma reality situation articles cases editing websites industry Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Apple Shulou Technology Shulou Tech Info MariaDB