title: Define an index on a new array in a loop?
body: <p>I have the following code:</p>
  
  <pre><code>$chart_data = array();
  foreach ($range as $range_day) {
    foreach ($numbers as $number) {
      if($range_day == $number['date']){
        @$chart_data[$range_day] += $number['events'];
      } else {
        if(isset($chart_data[$range_day])){
          $chart_data[$range_day] += 0;
        }
      }
    }
  }
  </code></pre>
  
  <p>This line: <code>$chart_data[$range_day] += 0;</code> was giving me an undefined index error, so I added the <code>isset</code> check, but it's not set so it wrecks my array. I know that it's not set, and I don't care, but I read all over that the <code>@</code> solution is in poor taste. How can I remove the error the correct way?</p>