Selecting every nth item from an array

后端 未结 8 1932
春和景丽
春和景丽 2021-02-02 13:41

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

8条回答
  •  無奈伤痛
    2021-02-02 14:31

    Try ArrayIterator::seek()

    Also, using one the new Spl datastructures might yield better results than using plain arrays.

提交回复
热议问题