May 15 2015

Which is more simple to use a while loop or a foreach loop of an array?

Comparison between foreach and while :-

Today we do one comparison between while and foreach to know that which one is more simple to be use .
Code for while:-While (($key = array_shift($b)) ! = = null))
Code for foreach:-Foreach($b as $key)

How to use:-



The foreach loop code execute about 8,000 times in 10 seconds while the while loop code execute about 6,000 times in 10 seconds. …
So ,Inspite of:-
While (($key = array_shift($b)) ! = = null))
We can use
Foreach($b as $key)


It's only fair to share...Share on Facebook
This entry was posted in Informational. Bookmark the permalink.
Total Views:


Comments are closed.