【发布时间】:2013-12-26 15:48:12
【问题描述】:
正在处理投票脚本,但我对投票的选项没有什么问题,创建了一个新数组。
实际示例数组包含 3 个子数组,其中包含选项、票数和百分比:
Array
(
[poll_options] => Array
(
[0] => Good
[1] => Bad
[2] => I do not care
)
[poll_answers] => Array
(
[0] => 3
[1] => 1
[2] => 1
)
[poll_percentage] => Array
(
[0] => 60
[1] => 20
[2] => 20
)
)
现在我需要创建一个新的值数组,结果必须是这样的:
Array
(
[0] => Array
(
[option] => Good
[answers] => 3
[percentage] => 60
)
[1] => Array
(
[option] => Bad
[answers] => 1
[percentage] => 20
)
[2] => Array
(
[option] => I do not care
[answers] => 1
[percentage] => 20
)
)
到目前为止,无论尝试什么,我都无法达到我想要的结果。 有什么想法吗?
【问题讨论】:
-
你尝试什么,发布代码! 10x
-
@HaimEvgi:发布我今天尝试的所有内容,我会达到问题的最大允许字符数。我认为对于这个问题,不需要像我那样发布更多代码。
标签: php arrays foreach while-loop array-merge