首页 > 后端开发 > php教程 > php 数组合并

php 数组合并

WBOY
发布: 2016-06-06 20:31:00
原创
897 人浏览过

array (size=5)
0 =>
array (size=1)
'txt' => string '中雨' (length=6)
1 =>
array (size=1)
'txt' => string '中雨' (length=6)
2 =>
array (size=1)
'txt' => string '雷阵雨' (length=9)
3 =>
array (size=1)
'txt' => string '雷阵雨' (length=9)
4 =>
array (size=1)
'txt' => string '雷阵雨' (length=9)


array (size=5)
0 =>
array (size=1)
'tmp_min' => string '23' (length=2)
1 =>
array (size=1)
'tmp_min' => string '22' (length=2)
2 =>
array (size=1)
'tmp_min' => string '23' (length=2)
3 =>
array (size=1)
'tmp_min' => string '23' (length=2)
4 =>
array (size=1)
'tmp_min' => string '23' (length=2)


array (size=5)
0 =>
array (size=1)
'date' => string '27日' (length=5)
1 =>
array (size=1)
'date' => string '28日' (length=5)
2 =>
array (size=1)
'date' => string '29日' (length=5)
3 =>
array (size=1)
'date' => string '30日' (length=5)
4 =>
array (size=1)
'date' => string '31日' (length=5)

合并成这种格式只能用foreach 吗,有没有php自带的函数可以执行;
array (size=5)
0 =>
array (size=1)
'tmp_min' => string '23' (length=2)
'date' => string '27日' (length=5)
'txt' => string '中雨' (length=6)
1 =>
array (size=1)
'date' => string '28日' (length=5)
'date' => string '27日' (length=5)
'txt' => string '中雨' (length=6)
2 =>
array (size=1)
'date' => string '29日' (length=5)
'date' => string '27日' (length=5)
'txt' => string '中雨' (length=6)
3 =>
array (size=1)
'date' => string '30日' (length=5)
'date' => string '27日' (length=5)
'txt' => string '中雨' (length=6)
4 =>
array (size=1)
'date' => string '31日' (length=5)
'date' => string '27日' (length=5)
'txt' => string '中雨' (length=6)

回复内容:

array (size=5)
0 =>
array (size=1)
'txt' => string '中雨' (length=6)
1 =>
array (size=1)
'txt' => string '中雨' (length=6)
2 =>
array (size=1)
'txt' => string '雷阵雨' (length=9)
3 =>
array (size=1)
'txt' => string '雷阵雨' (length=9)
4 =>
array (size=1)
'txt' => string '雷阵雨' (length=9)


array (size=5)
0 =>
array (size=1)
'tmp_min' => string '23' (length=2)
1 =>
array (size=1)
'tmp_min' => string '22' (length=2)
2 =>
array (size=1)
'tmp_min' => string '23' (length=2)
3 =>
array (size=1)
'tmp_min' => string '23' (length=2)
4 =>
array (size=1)
'tmp_min' => string '23' (length=2)


array (size=5)
0 =>
array (size=1)
'date' => string '27日' (length=5)
1 =>
array (size=1)
'date' => string '28日' (length=5)
2 =>
array (size=1)
'date' => string '29日' (length=5)
3 =>
array (size=1)
'date' => string '30日' (length=5)
4 =>
array (size=1)
'date' => string '31日' (length=5)

合并成这种格式只能用foreach 吗,有没有php自带的函数可以执行;
array (size=5)
0 =>
array (size=1)
'tmp_min' => string '23' (length=2)
'date' => string '27日' (length=5)
'txt' => string '中雨' (length=6)
1 =>
array (size=1)
'date' => string '28日' (length=5)
'date' => string '27日' (length=5)
'txt' => string '中雨' (length=6)
2 =>
array (size=1)
'date' => string '29日' (length=5)
'date' => string '27日' (length=5)
'txt' => string '中雨' (length=6)
3 =>
array (size=1)
'date' => string '30日' (length=5)
'date' => string '27日' (length=5)
'txt' => string '中雨' (length=6)
4 =>
array (size=1)
'date' => string '31日' (length=5)
'date' => string '27日' (length=5)
'txt' => string '中雨' (length=6)

不考虑三维数组么?

<code>参考:array_combine(array_column($arr, 'age'), array_column($arr, 'name'));
php版本至少需要5.5才可以用array_column
</code>
登录后复制
相关标签:
php
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板