title: for loop vs while loop vs foreach loop PHP
body: <p>1st off I'm new to PHP. I have been using for loop,while loop,foreach loop in scripts. I wonder </p>
  
  <ul>
  <li>which one is better for performance?</li>
  <li>what's the criteria to select a loop?</li>
  <li>which should be used when we loop inside another loop?</li>
  </ul>
  
  <p>the code which I'm stuck with wondering which loop to be used.</p>
  
  <pre><code>for($i=0;$i&lt;count($all);$i++)
  {
   //do some tasks here
   for($j=0;$j&lt;count($rows);$j++)
   {
    //do some other tasks here 
   }
  }
  </code></pre>
  
  <p>It's pretty obvious that I can write the above code using while. Hope someone will help me out to figure out which loop should be better to be used.</p>