👋 Enjoying the content? Subscribe to our Medium publication for more articles like this. 👇
Keep Learning

PHP Loops — Which is faster?

BY Atakan Demircioğlu
Table of Contents

Foreach vs for in PHP, which is the fastest loop in PHP?

PHP Loops — Which is faster? image 1

These are my notes about PHP loops, which are faster, and so on.

I just compared it in one way and wrote the test results. It is important what do yo do inside the looping.

Note: echo is affecting testing performance. But it is ok for getting an idea that what happens when loops are working.

Using reference in foreach

Completed in 0.00046801567077637 Seconds
Completed in 0.00078511238098145 Seconds


Is for loop faster than foreach?

What is the fastest loop?



How To Secure PHP Sessions?
My notes about how to secure PHP Sessions, what is session hijacking, and so on.atakde.medium.com

JIT Compiler in PHP
Here are my notes about the JIT compiler in PHP.atakde.medium.com

PHP Magic Methods Explained
PHP Magic methods explained. What are the PHP Magic methods?atakde.medium.com