时间:2021-07-01 10:21:17 帮助过:16人阅读
1.array_merge()函数合并数组
具体事例如下:
$a = array(
'where' => 'uid=1',
'order' => 'uid',
'limit' => '5'
);
$b = array(
'where' => 'uid=2',
'order' => 'uid desc',
);
$c = array_merge($a,$b);
print_r($c);
$d = array_merge($b,$a);
print_r($d);
输出结果如下:
注意where和uid字段,这两个字段是$a和$b数组中共有的字段,在注意结果中这两个字段值的区别,可以总结出什么呢?Array ( [where] => uid=2 [order] => uid desc [limit] => 5 )
Array ( [where] => uid=1 [order] => uid [limit] => 5 )
$a = array(
'where' => 'uid=1',
'order' => 'uid',
'limit' => '5'
);
$b = array(
'where' => 'uid=2',
'order' => 'uid desc',
);
$c = $a+$b;
print_r($c);
$d = $b+$a;
print_r($d);
输出结果如下:
如上,我们仍然关注where和order字段的值,可以得出什么结论呢?Array ( [where] => uid=1 [order] => uid [limit] => 5 )
Array ( [where] => uid=2 [order] => uid desc [limit] => 5 )
以上就介绍了php中合并数组的方法,包括了php,的方法方面的内容,希望对PHP教程有兴趣的朋友有所帮助。