2 回答

TA贡献1824条经验 获得超8个赞
使用数组映射。它遍历每个元素并创建新的元素数组,无论你想返回什么。在您的情况下,您希望删除 'weight' col,因此取消设置。
$array1 = [
[
'col_0' => '123',
'col_1' => '321',
'weight' => 1
],
[
'col_0' => '123',
'col_1' => '321',
'weight' => 1
],
[
'col_0' => '123',
'col_1' => '321',
'weight' => 1
],
[
'col_0' => '123',
'col_1' => '321',
'weight' => 1
],
[
'col_0' => '123',
'col_1' => '321',
'weight' => 1
],
];
$array2 = array_map(function($element) {
unset($element['weight']);
return $element;
}, $array1);

TA贡献1820条经验 获得超9个赞
- 2 回答
- 0 关注
- 122 浏览
添加回答
举报