Skip to content

Instantly share code, notes, and snippets.

@stemar
Last active December 7, 2019 00:06
Show Gist options
  • Save stemar/5190779 to your computer and use it in GitHub Desktop.
Save stemar/5190779 to your computer and use it in GitHub Desktop.
Remove a subset of an associative array by providing the keys.
<?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