Calculating the sum of an array in PHP
<p>I'm trying to set up a basic PHP code where it scans through numbers and calculates the total from a certain set of conditions. Here, I'm saying I want to add all the numbers between 100 and 200 that are even and multiples of 5. To do this, i thought I could first put those numbers into an array, then add up the array. </p>

<p>Something like this:</p>

<pre><code>&lt;?php
  $total = 0;
  $naturalNumber = array();
  $naturalNumber[] = $i;
  while ($i % 2 == 0 &amp;&amp; $i % 5 == 0) {
    for($i&gt;=100; $i &lt;=200; $i++) {
      $naturalNumber[] = $i;
      $total = array_sum($naturalNumber);
    } 
  }
  echo "&lt;p&gt;$total&lt;/p&gt;";
?&gt;
</code></pre>

<p>But error occurs: <code>cannot use [] for reading</code>, is there any semantic issues here as well?</p>

<p>Cheers!  </p>