Skip to content

Instantly share code, notes, and snippets.

@arlaneenalra
Last active December 28, 2015 06:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save arlaneenalra/7457767 to your computer and use it in GitHub Desktop.
Save arlaneenalra/7457767 to your computer and use it in GitHub Desktop.
A crude array_splice that preserves keys.
<?php
function array_splice_preserve ($input, $offset, $length, $replacement) {
$keys = array_keys($input);
$values = array_values($input);
array_splice($keys, $offset, $length, array_keys($replacement));
array_splice($values, $offset, $length, array_values($replacement));
return array_combine($keys, $values);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment