【发布时间】:2013-06-13 09:32:17
【问题描述】:
谁能告诉我如何使用 php 数组操作将第一个数组转换为第二个数组。
第一个数组:-
Array
(
[0] => Array
(
[actual_release_date] => 2013-06-07 00:00:00
[distributors] => 20th Century Fox / 20th Century Fox Animation / Fox 2000 Pictures / Fox Searchlight
)
[1] => Array
(
[actual_release_date] => 2013-06-28 11:11:00
[distributors] => 20th Century Fox / 20th Century Fox Animation / Fox 2000 Pictures / Fox Searchlight
)
)
第二个数组:-
Array
(
[0] => Array
(
[actual_release_date] => array( 0=>2013-06-07 00:00:00 , 1=> 2013-06-28 11:11:00 )
[distributors] => 20th Century Fox / 20th Century Fox Animation / Fox 2000 Pictures / Fox Searchlight
)
)
如果第二个元素是共同的,而第一个元素是不同的,那么我们必须将它分组到一个数组中。
提前致谢。
【问题讨论】:
-
你尝试过简单的旧
foreach里面有if吗? -
如果两个字段都通用?
-
@Jack 只有一个会在实际发布日期
-
@VtrioAjeesh 在这种情况下,Baba 的解决方案不会为该场景提供正确的结果。仅供参考。