Skip to content

Instantly share code, notes, and snippets.

@llbbl
Forked from arlaneenalra/array_splice.php
Last active December 28, 2015 06:29
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 llbbl/7457776 to your computer and use it in GitHub Desktop.
Save llbbl/7457776 to your computer and use it in GitHub Desktop.
<?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