Announcement

Collapse
No announcement yet.

for vs foreach vs while which is faster for iterating through arrays in php

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • for vs foreach vs while which is faster for iterating through arrays in php

    which one is the fastest for iterating through arrays in php?
    Does another exist which is also faster for iterating through arrays?

  • #2
    Make a benchmark test.

    There is no major "performance" difference, because the differences are located inside the logic.
    • You use foreach for array iteration, without integers as keys.
    • You use for for array iteration with integers as keys.
    • etc.

    Comment

    Working...
    X