<?php namespace app\index\controller; class Index{ public function index(){ //dump(config()); $conf1 = [ 'username' => 'aa' ]; $conf2 = [ 'username' => 'bb' ]; echo '<pre>'; print_r(array($conf1, $conf2)); } }
dump或者print_r 打印出来都是两个
array_merge() : 把两个数组合并为一个数组,
注意:如果两个或更多个数组元素有相同的键名,则最后的元素会覆盖其他元素
<?php $a1=array("a"=>"red","b"=>"green"); $a2=array("c"=>"blue","b"=>"yellow"); print_r(array_merge($a1,$a2)); ?>
$a2数组键名为 'b'=>'yellow',替换了$a1数组键名为 'b'=>'green' 结果就是 :Array ( [a] => red [b] => yellow [c] => blue ) 望采纳
写错了,打印应该是array_merge()