欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

php 数组合并

程序员文章站 2022-05-29 17:40:48
...
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)

不考虑三维数组么?

参考:array_combine(array_column($arr, 'age'), array_column($arr, 'name'));
php版本至少需要5.5才可以用array_column
相关标签: php