Last active
December 7, 2019 00:06
-
-
Save stemar/5190779 to your computer and use it in GitHub Desktop.
Remove a subset of an associative array by providing the keys.
This file contains 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 | |
/** | |
* Remove a subset of an associative array by providing the keys. | |
* | |
* @param array $assoc | |
* @param array $keys | |
* @return array | |
*/ | |
function array_remove(array $assoc, array $keys) { | |
return array_diff_key($assoc, array_flip($keys)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment