Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

array filter use key

$my_array = ['foo' => 1, 'hello' => 'world'];
$allowed  = ['foo', 'bar'];
$filtered = array_filter(
    $my_array,
    function ($key) use ($allowed) {
        return in_array($key, $allowed);
    },
    ARRAY_FILTER_USE_KEY
);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #array #filter #key
ADD COMMENT
Topic
Name
4+6 =