array:2 [▼
0 => array:6 [▼
"" => "что то не нужное"
"brand" => "Бренд"
"code" => "Артикул"
"price" => "цена"
"quantity" => "кол-во"
"name" => "нейм"
]
]
<?php
function walk_recursive_remove (array $array, callable $callback) {
foreach ($array as $k => $v) {
if (is_array($v)) {
$array[$k] = walk_recursive_remove($v, $callback);
} else {
if ($callback($v, $k)) {
unset($array[$k]);
}
}
}
return $array;
}
$array = [[
"" => "что то не нужное",
"brand" => "Бренд",
"code" => "Артикул",
"price" => "цена",
"quantity" => "кол-во",
"name" => "нейм"
]];
$filtered = walk_recursive_remove($array, function ($value, $key) {
return empty($value) || empty($key);
});
var_dump($filtered);
$array = [
[
"" => "что то не нужное",
"brand" => "Бренд",
"code" => "Артикул",
"price" => "цена",
"quantity" => "кол-во",
"name" => "нейм",
],
];
$filter = function ($value, $key) {
return !empty($key);
};
$result = array_map(function ($value) use ($filter) {
return array_filter($value, $filter, ARRAY_FILTER_USE_BOTH);
}, $array);