大家好我在php中有数组问题我想从现有数组创建新数组并获取两者的值,我有这样的代码:
Array(
[header] => Array
(
[1] => Array
(
[A] => data_nomor_identitas
[B] => data_map_latitude
[C] => data_map_longitude
[D] => data_responden_nik
)
)
[values] => Array
(
[2] => Array
(
[A] => 32.14.01.06.00000001
[B] => 0
[C] => 0
[D] => 3214000002
)
[3] => Array
(
[A] => 32.14.01.06.00000002
[B] => 0
[C] => 0
[D] => 3214000002
)
[4] => Array
(
[A] => 32.14.01.06.00000002
[B] => 0
[C] => 0
[D] => 3214000002
)
)
)
然后我想要这样的结果:
[values] => Array
(
[2] => Array
(
data_nomor_identitas => 32.14.01.06.00000001
data_map_latitude => 0
data_map_longitude => 0
data_responden_nik => 3214000002
)
[3] => Array
(
data_nomor_identitas => 32.14.01.06.00000002
data_map_latitude => 0
data_map_longitude => 0
data_responden_nik => 3214000002
)
[4] => Array
(
data_nomor_identitas => 32.14.01.06.00000002
data_map_latitude => 0
data_map_longitude => 0
data_responden_nik => 3214000002
)
)
谢谢你以前。对不起我的英文
答案 0 :(得分:0)
给这个镜头。
Array combine使用一个数组中的值作为键,将另一个数组中的值作为值
$newArray=array();
foreach ($array['values'] as $set){
$newArray[]=array_combine($array['header'],$set);
}
var_dump($newArray);