You're going to have to loop through the array in some fashion. Obviously you have to look at each element to determine if it's in your wanted set, right? grep is just a single loop and is probably faster than doing a foreach and pushing the matching elements onto a new array. When in doubt, Benchmark.