php 把一个一维数组的值依次赋值到二维数组中的每一项

Array
(

[0] => 1
[1] => 4
[2] => 2
[3] => 6

)

Array
(

[0] => Array
(
[field_name] => 镇*
[field_id] => d14
[create_time] => 1490235566
) [1] => Array
(
[field_name] => 小邢
[field_id] => d13
[create_time] => 1490235525
) [2] => Array
(
[field_name] => 这是场地
[field_id] => d12
[create_time] => 1490235386
) [3] => Array
(
[field_name] => 村南
[field_id] => d11
[create_time] => 1489734050
)

)

希望能把最上面那个一维数组对应的添加到二维数组里,两个数组的key名相同

需要这样的结果:

Array
(

[0] => Array
(
[field_name] => 镇*
[field_id] => d14
[create_time] => 1490235566
[number]=>1
) [1] => Array
(
[field_name] => 小邢
[field_id] => d13
[create_time] => 1490235525
[number]=>4
) [2] => Array
(
[field_name] => 这是场地
[field_id] => d12
[create_time] => 1490235386
[number]=>2
) [3] => Array
(
[field_name] => 村南
[field_id] => d11
[create_time] => 1489734050
[number]=>6
)

)

办法:

foreach($data2 as $key=> &$item)
{
$item['number'] = $data1[$key];
}
上一篇:Oracle_高级功能(3) synonym和database link


下一篇:servlet的doPost 和doGet和web文件结构