DEV Community

loading...

Discussion on: A Slow Death by For Loops

Collapse
vasilvestre profile image
Valentin Silvestre

As you can see here : 3v4l.org/7Kvf5 , PHP7 made foreach() 50% as fast as for(). It depend of version tho
To be honest, that's premature optimisation to use for() instead of foreach() from now. If you really need high-performance, you shouldn't use PHP imo

Thread Thread
yechielk profile image
Yechiel Kalmenson

Unfortunately, sometimes those decisions are made for you by others...

Thread Thread
vasilvestre profile image
Valentin Silvestre

Sometimes it's worth mentionning the fact that with low effort, you can improve a lot the process and (because that's the only thing that interest people) the result