【发布时间】:2019-05-10 19:44:14
【问题描述】:
我在 Google 上找不到它,或者使用了错误的关键字。如何将变量值“[contestantvariable_number-fieldname]”合并到多维数组?
数组示例:
array (
[contestant1-gender] => M
[contestant1-first-name] => Wyatt
[contestant1-last-name] => Heath
[contestant1-occupation] => Ipsa architecto vol
[contestant1-email] => dipuxo@mailinator.com
[contestant1-phone] => +1 (992) 741-8123
[contestant2-gender] => M
[contestant2-first-name] => Leonard
[contestant2-last-name] => Acosta
[contestant2-occupation] => Aut sunt qui offici
[contestant2-email] => sajomogylu@mailinator.com
[contestant2-phone] => +1 (462) 687-8393
[department] => In mollitia impedit
[street] => Sed error magnam obc
[number] => 41
[bus] => In iste ut perspicia
[postalcode] => Commodo impedit vol
[city] => Ad iure veniam veli
[country] => nl
)
这样的:
Array (
[0] => contestant (
[0] => gender ( )
[1] => first-name ()
)
[1] => contestant (
[0] => gender ( )
[1] => first-name ()
)
[2] => contestant (
[0] => gender ( )
[1] => first-name ()
)
)
【问题讨论】:
-
到目前为止你有没有尝试过?
-
你可以使用函数
array_merge_multidimesional你只需要先写它:D -
结果中的
()应该是什么? -
请参阅stackoverflow.com/questions/33854400/… 和stackoverflow.com/questions/51573147/…,了解将
contestant-gender等键转换为嵌套数组的方法。
标签: php