Quick actions

cmd+k|ctrl+k

Navigation

Languages

Array Filter by Key

Snippet info

Language

Php

Visibility

public

Author

bibitahabibi

Created

2020-07-15T08:34:15Z

Updated

2020-07-15T08:34:15Z

<?php

$list = [
    'a' => 'A',
    'b' => 'B',
    'c' => 'C'
];

$selected = ['c', 'b'];

print_r(array_filter($list, function ($item) use ($selected) {
    return in_array($item, $selected, true);
}, ARRAY_FILTER_USE_KEY));
INFO