Array

PHP Array Delete

Nov 25, 2011

Can PHP really be missing a way of deleting items from an array based on the key? Seems so, so here am am just sharing a snippet of code that lets you do just that. This function will work with any number of array keys and does some clever shunting around with the array_flip and array_slice functions. // utility to remove array items from the key function array_remove_key() { $args = func_get_args(); return array_diff_key($args[0],array_flip(array_slice($args,1))); } // usage...