thinkphp5 合并数组
时间: 2023-10-20 14:31:54 浏览: 130
ThinkPHP 2.0开发技巧
在thinkphp5中,合并数组的方法与thinkphp3.2有所不同。在thinkphp5中,可以使用array_merge函数来合并数组。下面是一个示例代码:
```
//声明三个数组(N个同下)
// $list是二维数组 $list['x1'] 表示从list数组中取出x1数组
$x1 = $list['x1'];
$x2 = $list['x2'];
$x3 = $list['x3'];
$result1 = array_merge($x1, $x2); //数组合并 (x1 x2)
$result2 = array_merge($result1, $x3); //$result1 x3
//打印结果
echo "<pre>";
print_r($result2);
echo "</pre>";
```
这段代码会将x1、x2和x3数组合并成一个新的数组$result2,并打印出合并后的结果。请注意,这里使用了array_merge函数来进行数组的合并操作。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [php 多个数组合并(在thinkphp5的控制器里写的)](https://blog.csdn.net/qq_43503385/article/details/105466326)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [Thinkphp5.1 合并后的数组进行排序之后分页](https://blog.csdn.net/qq_30986969/article/details/124820054)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [thinkphp 3.2框架视图模型 实例视图查询结果的二维数组合并操作示例](https://download.csdn.net/download/weixin_38615783/12927366)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]
阅读全文