Remove element from array using array_map

I think array_map is not designed for your needs, because it's apply a callback for each element of your array. But array_filter does :

$array = array_filter($array, function($e) {
    return is_numeric($e);
});

Or even shorter :

$array = array_filter($array, 'is_numeric');

If you wanted to return false in your array_map you can then apply array_filter to clean it up.

$stores = [];

$array = array_map(function ($store) {
    if ($true) {
        return [
            'name' => $store['name'],
        ];
    } else {
        return false;
    }
}, $stores);

array_filter($array);

Tags:

Php