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

php 数组合并

WBOY
WBOY原创
2016-06-06 20:31:00877浏览

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>
声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn