PHP Classes

I agree with you in general.

Recommend this page to a friend!

      PHP Classes blog  >  You have doing PHP it...  >  All threads  >  I agree with you in general.  >  (Un) Subscribe thread alerts  
Subject:I agree with you in general.
Summary:Loops for arrays and iterators for other data structures.
Messages:1
Author:Oleg Zorin
Date:2016-10-12 12:02:13
Update:2016-10-12 16:57:51
 

  1. I agree with you in general.   Reply   Report abuse  
Picture of Oleg Zorin Oleg Zorin - 2016-10-12 16:57:51
I agree with you in general.
> Never loop through a problem that should be solved by iteration.

But as long as you talking about arrays in most cases you should use loops. If it is not true - you should think well about data structure and logic of your application. Your arrays shouldn't be huge (probably data should store in other way).

And if you talking about processing of data in DB (any kind, even files) or indexing some data for better search perfomance (for example index your products data in search engine) and other similar tasks - so, iteration is right a way.

Actualy the first link in your post said the same idea.