array_merge- Merging one or more arrays
Array_merge () Merges the cells of one or more arrays, and the values in an array are appended to the previous array. Returns an array as the result.
If the input array has the same string key name, the value following the key name overrides the previous value. However, if the array contains numeric key names, subsequent values will not overwrite the original values, but are appended to the back.
If only one array is given and the array is a numeric index , the key name is re- indexed in a sequential manner.
array_merge will return NULL if any of the arguments are NULL。
For example:
$array 1 = NULL;
$array 2 = Array (1 = "data");
$result = Array_merge ($array 1, $array 2);
Var_dump ($result); The result is null, so when writing the SQL statement to get the result set, be aware that if (empty ($resut)) {$result =array ();} is assigned an empty array and then merged with the other arrays.
Example :
//The new logic$agent _id=$location _model->where ("id="$location _id' ")->getfield (' agent_id ')); //re-query authorized operators (to exclude authorized merchants)if(!Empty($agent _id)){ $TPL _list2=$TPL _model->where ("Status=1 and agent_range=2 and agent_id in ($agent _id) and Supplier_id= "")->field ($field)->order (' id desc ')Select (); } if(Empty($TPL _list2)){ $TPL _list2=Array(); } //re-search authorized all operators$TPL _list3=$TPL _model->where ("Status=1 and Agent_range=1")->field ($field)->order (' id desc ')Select (); if(Empty($TPL _list3)){ $TPL _list3=Array(); } //array_merge would return null if any of the arguments is null$TPL _list_merge=Array_merge($TPL _list1,$TPL _list2,$TPL _list3);
The above describes the Array_merge function considerations, including the content of the index, I hope that the PHP tutorial interested in a friend helpful.