tags:

views:

49

answers:

3

I have this $array in which the index key could appear in any random order:

array(4) {
  ["foo"]=> bool(false)
  ["index"]=> bool(false)
  ["bar"]=> bool(true)
  ["biff"]=> bool(false)
}

Without adjusting the position of the elements or changing the key or value, how do I remove the index element, resulting in a new $array?

array(3) {
  ["foo"]=> bool(false)
  ["bar"]=> bool(true)
  ["biff"]=> bool(false)
}
+3  A: 
unset($array['index']);
erenon
+1 for the help.
Jeff
+5  A: 

Use:

unset($array['index']);
Tomas Markauskas
Ya know, I'm too tired to be working right now. Thanks, folks. =)
Jeff
+1  A: 

unset($array['index']); is what you're looking for. This will work even if there is no 'index' key in the array.

David Pfeffer