title: php add key value to array
body: <p>So i get objects from the database and i want to put the id and the points inside an array.
  And everytime getIscorrect equals true the value of the id must be increased by 1.</p>
  
  <pre><code>$answers = array();
      $return = $this-&gt;_quizMapper-&gt;getAll();
      foreach($return as $answer){
          if($answer-&gt;getIscorrect() == true){
              if(!($answers[$answer-&gt;getID()])){
                  $answers[$answer-&gt;getID()] = 1;
              }
              else{
                  $newPoints = $answers[$answer-&gt;getID()] + 1;
                  $answers[$answer-&gt;getID()] = $newPoints;
              }
          }
      }
  </code></pre>
  
  <p>but i keep on getting error: PHP Notice:  Undefined index: on this line                 <code>if(!($answers[$answer-&gt;getID()])){</code></p>