Skip to content

Instantly share code, notes, and snippets.

@kolodziej
Last active December 23, 2015 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kolodziej/6654344 to your computer and use it in GitHub Desktop.
Save kolodziej/6654344 to your computer and use it in GitHub Desktop.
<?php
function array_delete(array &$array, $elements) {
//jeśli parametr $elements jest tablicą kluczy do usunięcia
if (is_array($elements)) {
//ile elementów do usunięcia
$toDelete = count($elements);
//ile usunięto poprawnie
$deleted = 0;
foreach ($elements as $index) {
if (unset($array[$index])) $deleted++;
}
if ($toDelete == $deleted)
return true;
else
return false;
} else {
return unset($array[$elements]);
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment