title: Foreach loop vs while loop results
body: <p>I have a bit of dilemma, In PHP both foreach loop and while loop seem to do exactly the same thing in this situation:</p>
  
  <pre><code>foreach($execute-&gt;result as $item){
      echo $item['user_pass'].'&lt;br /&gt;';
  }
  </code></pre>
  
  <p>AND</p>
  
  <pre><code>while($row = mysqli_fetch_assoc($execute-&gt;result)){
      echo $row['user_pass'].'&lt;br /&gt;';
  }
  </code></pre>
  
  <p>My question is are there any real differences...? when would be better to use one over another or is it fine to use both....? Does any of these two give you potential greater felxebility...?</p>