title: PHP - Using a for loop to count elements in an array instead of using built-in PHP function count
body: <p>I'm working on getting a better understand on for loops and how I can use a <code>for loop</code> to count elements in an array without the built-in PHP function <code>count</code>.</p>
  
  <p>I've been able to do it with the foreach loop, (count the elements in an array) but for some reason the <code>for loop</code> isn't working?</p>
  
  <p><strong>Foreach loop this works:</strong></p>
  
  <pre><code>$month_temp = "78, 60, 62, 68, 71, 68, 73, 85, 66, 64, 76, 63, 81, 76, 73, 68, 72, 73, 75, 65, 74, 63, 67, 65, 64, 68, 73, 75, 79, 73";
  
  $temp = explode(',', $month_temp);
  
  $count = 0;
  
  foreach ($temp as $value) {
      $count++;
  }
  print_r($count);
  </code></pre>
  
  <p>Can someone point out what I'm doing wrong? (I end up with some kind of endless loop without anything being displayed)</p>
  
  <p><strong>For loop not working:</strong></p>
  
  <pre><code>$month_temp = "78, 60, 62, 68, 71, 68, 73, 85, 66, 64, 76, 63, 81, 76, 73, 68, 72, 73, 75, 65, 74, 63, 67, 65, 64, 68, 73, 75, 79, 73";
  
  $temp = explode(',', $month_temp);
  
  $count = 0;
  
  for ($i = 0; $i &lt; $temp; $i++) {
      $count++;
  }
  print_r($count);
  </code></pre>