Php 用编号键替换命名键
在多维数组中,用编号键替换命名键的最有效、最简洁的方法是什么 我的阵列:Php 用编号键替换命名键,php,multidimensional-array,Php,Multidimensional Array,在多维数组中,用编号键替换命名键的最有效、最简洁的方法是什么 我的阵列: Array ( [0] => Array ( [Property] => Brock [Meint. Type] => grounds [Maint. Task] => plow snow [Status] => cancelled [Starte
Array
(
[0] => Array
(
[Property] => Brock
[Meint. Type] => grounds
[Maint. Task] => plow snow
[Status] => cancelled
[Started] =>
[Completed] =>
[Comments] =>
)
[1] => Array
(
[Property] => Brock
[Meint. Type] => grounds
[Maint. Task] => plow snow
[Status] => pending
[Started] => 2010-01-16
[Completed] =>
[Comments] =>
)
[2] => Array
(
[Property] => Brock
[Mains. Type] => grounds
[Maint. Task] => plow snow
[Status] => complete
[Started] => 2010-01-16
[Completed] => 2010-01-16
[Comments] =>
)
[3] => Array
(
[Property] => Brock
[Mains. Type] => grounds
[Maint. Task] => plow snow
[Status] => in progress
[Started] => 2014-01-16
[Completed] => 2014-01-16
[Comments] =>
)
[4] => Array
目标是将[Property]替换为[0],[Maint.Type]替换为[1](应该用方括号括起来,它们将被自动删除),[Maint.Task]替换为[2],[Status]替换为[3]等等,用于每个子数组
$modified_array = array_map('array_values', $arr);
说明:将函数应用于$arr
数组中的每个元素