What would be the most efficient way to select every nth item from a large array? Is there a \'smart\' way to do it or is looping the only way?
Some points to c
I recommend to using array_slice
array_slice
$count = count($array) ; for($i=205;$i<$count;$i+=205){ $result[] = array_slice($array,$i,1); }
If your array was numerically indexed, this would be very fast:
$count = count($array) ; for($i=205;$i<$count;$i+=205){ $result[] = $array[$i]; }