You might find my answer to a similar question at Re: Slice of a multidimensional array useful. There are a couple of function definitions there, one of which would do exactly what you want.
Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller