1.array_merge()合并
例子
代码如下 | |||||
$array = array('a'=>'bb');
输出结果为
Array ( [a] => bb [b] => cc ) |
代码如下 | |
|
代码如下 | |
|
Results after operation
Warning: array_merge() [function.array-merge]: Argument #1 is not an array in E:test1.php on line 4
Tell us that we must have an array, then I have many ways to solve this,
1. Use is_array() to make a judgment, but you will find that if there are too many arrays to merge, the judgments one by one are unreasonable. Later, I found that the data type can be converted
The code is as follows | |||||
$array = 1;//array('a'=>'bb');
The output results no longer report errors
Array ( [0] => 1 [b] => cc ) |
1.array_merge() merge example code is as follows $array = array('a'='bb'); $ array2 = array('b'='cc'); $array3 = array_merge($array,$array2); The output result is Array ( [a] = bb [b] = cc ) above...