$oldArr = [
['a', 1],
['', 2],
['', 3],
['b', 4],
['', 5],
['c',6],
['',7]
];
转换为
$newArr = [
'a'=>'1,2,3',
'b'=>'4,5',
'c'=>'6,7'
]
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
难道不应该想想,数组为什么会拼接成这样么?
感觉从数据库取出来的时候,可以用mysql内置函数处理
例如concat()或者concat_group()