Presently I'm using array_values(array_filter($arr)) to remove false values from an array.
It feels like there's most likely a built-in function that does this more tersely.
Presently I'm using array_values(array_filter($arr)) to remove false values from an array.
It feels like there's most likely a built-in function that does this more tersely.
Sure.
function f($arr) {return array_values(array_filter($arr));}
Now you can do:
$b = f($a);
Much more terse! Much less readable.
array_values(array_filter(..)) is very explicit as to what it does. This is many times more important than terseness.