Rumah >pembangunan bahagian belakang >tutorial php >PHP array_merge()函数实现多个数组合并
php代码段:
$arr1 = array( 'name' => '小明', 'sex' => 1, 'age' => 24, );$arr2 = array( 'type' => 'IT', 'status' => '正常', 'flag' => 1, 'sort' => 100,);//假如以上两个数组是从两个表里读取的数据,现在需要将他们合并到一起$userInfo = array_merge($arr1, $arr2);print_r($userInfo);
output:
array(
'name' => '小明',
'sex' => 1,
'age' => 24,
'type' => 'IT',
'status' => '正常',
'flag' => 1,
'sort' => 100,
);