Is it possible without looping through the array to remove a every element with a certain key in one of the dimensions? Say you have an array 3x5 in size:
$array[0-2, 0-4]
and you have values in all those positions. Does anybody know how to remove all the array values that have a "3" key in the second position without looping through them? In other words...unset the following:
$array[0,3]
$array[1,3]
$array[2,3]
Remove a dimension of an array
Moderator: General Moderators
Re: Remove a dimension of an array
If the dimensions are fixed then you can use a bunch of unsets. Otherwise you'll need a loop somewhere.
-
Mark Baker
- Forum Regular
- Posts: 710
- Joined: Thu Oct 30, 2008 6:24 pm
Re: Remove a dimension of an array
array_walk(), but it's still basically implementing a loop