在 php 中添加关联数组值?
我有一个具有以下属性的数组:
Array
(
[0] => Array
(
[project] => test proposal
[type] => pending
[0] => 10,000
[1] => 10,000
[2] => 5,000
[3] => 0
[4] => 0
[5] => 0
[6] => 0
[7] => 0
[8] => 0
[9] => 0
[10] => 0
[11] => 0
)
[1] => Array
(
[project] => test 3
[type] => won
[0] => 0
[1] => 0
[2] => 20,000
[3] => 20,000
[4] => 10,000
[5] => 0
[6] => 0
[7] => 0
[8] => 0
[9] => 0
[10] => 0
[11] => 0
)
[2] => Array
(
[project] => Test 3
[type] => pending
[0] => 8,333
[1] => 8,333
[2] => 8,333
[3] => 0
[4] => 0
[5] => 0
[6] => 0
[7] => 0
[8] => 0
[9] => 0
[10] => 0
[11] => 0
)
)
我想将最后一个项目推入数组,该数组组合了所有其他项目的值,项目和类型可以为空。所以结果将是:
Array
(
[0] => Array
(
[project] => test proposal
[type] => pending
[0] => 10,000
[1] => 10,000
[2] => 5,000
[3] => 0
[4] => 0
[5] => 0
[6] => 0
[7] => 0
[8] => 0
[9] => 0
[10] => 0
[11] => 0
)
[1] => Array
(
[project] => test 3
[type] => won
[0] => 0
[1] => 0
[2] => 20,000
[3] => 20,000
[4] => 10,000
[5] => 0
[6] => 0
[7] => 0
[8] => 0
[9] => 0
[10] => 0
[11] => 0
)
[2] => Array
(
[project] => Test 3
[type] => pending
[0] => 8,333
[1] => 8,333
[2] => 8,333
[3] => 0
[4] => 0
[5] => 0
[6] => 0
[7] => 0
[8] => 0
[9] => 0
[10] => 0
[11] => 0
)
[3] => Array
(
[project] =>
[type] =>
[0] => 18,333
[1] => 18,333
[2] => 33,333
[3] => 20,000
[4] => 10,000
[5] => 0
[6] => 0
[7] => 0
[8] => 0
[9] => 0
[10] => 0
[11] => 0
)
)
I have an array with the following properties:
Array
(
[0] => Array
(
[project] => test proposal
[type] => pending
[0] => 10,000
[1] => 10,000
[2] => 5,000
[3] => 0
[4] => 0
[5] => 0
[6] => 0
[7] => 0
[8] => 0
[9] => 0
[10] => 0
[11] => 0
)
[1] => Array
(
[project] => test 3
[type] => won
[0] => 0
[1] => 0
[2] => 20,000
[3] => 20,000
[4] => 10,000
[5] => 0
[6] => 0
[7] => 0
[8] => 0
[9] => 0
[10] => 0
[11] => 0
)
[2] => Array
(
[project] => Test 3
[type] => pending
[0] => 8,333
[1] => 8,333
[2] => 8,333
[3] => 0
[4] => 0
[5] => 0
[6] => 0
[7] => 0
[8] => 0
[9] => 0
[10] => 0
[11] => 0
)
)
I'd like to push a last item to the array that combines the values of all of the others, project and type can be blank. So the outcome would be:
Array
(
[0] => Array
(
[project] => test proposal
[type] => pending
[0] => 10,000
[1] => 10,000
[2] => 5,000
[3] => 0
[4] => 0
[5] => 0
[6] => 0
[7] => 0
[8] => 0
[9] => 0
[10] => 0
[11] => 0
)
[1] => Array
(
[project] => test 3
[type] => won
[0] => 0
[1] => 0
[2] => 20,000
[3] => 20,000
[4] => 10,000
[5] => 0
[6] => 0
[7] => 0
[8] => 0
[9] => 0
[10] => 0
[11] => 0
)
[2] => Array
(
[project] => Test 3
[type] => pending
[0] => 8,333
[1] => 8,333
[2] => 8,333
[3] => 0
[4] => 0
[5] => 0
[6] => 0
[7] => 0
[8] => 0
[9] => 0
[10] => 0
[11] => 0
)
[3] => Array
(
[project] =>
[type] =>
[0] => 18,333
[1] => 18,333
[2] => 33,333
[3] => 20,000
[4] => 10,000
[5] => 0
[6] => 0
[7] => 0
[8] => 0
[9] => 0
[10] => 0
[11] => 0
)
)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
也许像这样?:
like this perhaps?: