我有两个来自HTML表单的数据数组。
Array1(payment_descriptions)看起来像这样:
["1st Desc","2nd Desc","3rd Desc"]
字符串
Array2(payment_amounts)是这样的:
["100.10","10.50","39.99"]
型
有没有一种方法可以将这些数组(付款)合并组合起来,使最终结果看起来像这样?
[{
"description": "1st Desc",
"amount": "100.10"
}, {
"description": "2nd Desc",
"amount": "10.50"
}, {
"description": "3rd Desc",
"amount": "39.99"
}]
型
1条答案
按热度按时间ovfsdjhp1#
你可以用简单的
array_combine()
和foreach()
循环来实现:字符串
DEMO:https://3v4l.org/1tP4c
array_combine()
:型
DEMO:https://3v4l.org/6FVHe