Skip to content

Instantly share code, notes, and snippets.

@CarpeNoctem
Created February 11, 2014 07:49
Show Gist options
  • Save CarpeNoctem/8930726 to your computer and use it in GitHub Desktop.
Save CarpeNoctem/8930726 to your computer and use it in GitHub Desktop.
PHP function I needed, that I thought might be useful for others as well. Like array_pop(), but for a specific array element instead of the very last one.
<?
// Dec 2013 - CarpeNoctem
// Like array_pop(), for a specific array element instead of the very last one.
function pull(&$array,$key)
{
$ret = $array[$key];
unset($array[$key]);
return($ret);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment