我有一个看起来像这样的 php 数组:
Array
(
[0] => Array
(
[0] => name_first
[1] => name_second
[2] => age
)
[1] => Array
(
[0] => firstname1
[1] => surname1
[2] => age1
)
[2] => Array
(
[0] => firstname2
[1] => surname2
[2] => age2
)
)
我想使用前三个值(它们确实改变了),如果有一个下划线的值(如本例中的 name_first 和 name_second),则将数组重新构造为:
Array
(
[0] => Array
(
[name] => Array
(
[first] => firstname1
[second] => surname1
)
[age] => age1
)
[1] => Array
(
[name] => Array
(
[first] => firstname2
[second] => surname2
)
[age] => age2
)
)
我已经为此工作了 2 天,但我无法提出解决方案,所以我的问题是:我怎样才能以有效的方式实现这一目标?