Created
May 15, 2016 13:26
-
-
Save insideone/fb0595cfb3874efc67e90e289b02b608 to your computer and use it in GitHub Desktop.
PHP: array_filter_key
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @param array $ar Фильтруемый массив | |
* @param string $callback Имя функции-фильтра | |
* return array Результирующий массив | |
*/ | |
function array_filter_key($ar, $callback = 'empty') | |
{ | |
$ar = (array)$ar; | |
return array_intersect_key($ar, array_flip(array_filter(array_keys($ar), $callback))); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment