Created
January 19, 2012 14:49
-
-
Save jasonreposa/1640416 to your computer and use it in GitHub Desktop.
Array splice with preserve 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
function array_psplice(&$array, $offset = 0, $length = 1) { | |
$return = array_slice($array, $offset, $length, true); | |
foreach ($return as $key => $value) { | |
unset($array[$key]); | |
} | |
return $return; | |
} |
pure and simple :)
How the heck is that supposed to be useful?!?
awesome! thanks
I love that this is still useful! I haven't programmed PHP in at least 6 years. 👍
Sweet solutions in 2021!!!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This was the first Google result for array_splice that preserves keys. Thank you!