title: Notice: Undefined index when trying to increment an associative array in PHP
body: <p>I'm trying to increment the value for $variable each time a duplicate variable occurs. I'm not sure if this is syntactically correct, but I think this is semantically correct. var_dump seems to spit out the correct outputs, but i get this error: Notice: Undefined index...</p>
  
  <pre><code>$newarray = array();
  foreach ($array as $variable)
  {
      $newarray[$variable]++; 
      var_dump($newarray);
  }
  </code></pre>
  
  <p>$array = (0 => h, 1 => e, 2 => l, 3=> l, 4=> o);</p>
  
  <p>goal:</p>
  
  <pre><code>'h' =&gt; int 1
  'e' =&gt; int 1
  'l' =&gt; int 2
  'o' =&gt; int 1
  </code></pre>
  
  <p>My code works, it's just that I get some weird NOTICE.</p>