title: PHP in_array() not working properly
body: <p>I have an <code>if</code> statment below that checks if a value is present in an array and adds it in there if it's not.
  Apparently even if the value is in the array, it triggers it again.</p>
  
  <p>As far as I understand, it should only display 1 of each value, because it will only trigger 3 times, like this:</p>
  
  <pre><code>Digital Photography -&gt; 0
  Step by Step Macintosh Training -&gt; 0
  How to become a Powerful Speaker -&gt; 0
  </code></pre>
  
  <p>The code:</p>
  
  <pre><code>if (!in_array($unit['course_name'], $courseList)) {
  
    $courseList[$unit['course_name']]['name'] = $unit['course_name'];
    $courseList[$unit['course_name']]['seconds'] = 0;
    echo $courseList[$unit['course_name']]['name'] . ' -&gt; ' . $courseList[$unit['course_name']]['seconds'];
    echo "&lt;BR&gt;";
  
  }
  </code></pre>
  
  <p>But it outputs:</p>
  
  <pre><code>Digital Photography -&gt; 0
  Step by Step Macintosh Training -&gt; 0
  Step by Step Macintosh Training -&gt; 0
  Step by Step Macintosh Training -&gt; 0
  How to become a Powerful Speaker -&gt; 0
  How to become a Powerful Speaker -&gt; 0
  </code></pre>
  
  <p>Here is the <code>var_dump($unit)</code>:</p>
  
  <pre><code>array(8) { ["author_name"]=&gt; string(10) "tuiuiu_dev" [0]=&gt; string(10) "tuiuiu_dev" ["course_name"]=&gt; string(19) "Digital Photography" [1]=&gt; string(19) "Digital Photography" ["unit_id"]=&gt; string(3) "181" [2]=&gt; string(3) "181" ["unit_quantity"]=&gt; string(1) "1" [3]=&gt; string(1) "1" } 
  array(8) { ["author_name"]=&gt; string(15) "William Merussi" [0]=&gt; string(15) "William Merussi" ["course_name"]=&gt; string(31) "Step by Step Macintosh Training" [1]=&gt; string(31) "Step by Step Macintosh Training" ["unit_id"]=&gt; string(3) "227" [2]=&gt; string(3) "227" ["unit_quantity"]=&gt; string(1) "1" [3]=&gt; string(1) "1" } 
  array(8) { ["author_name"]=&gt; string(15) "William Merussi" [0]=&gt; string(15) "William Merussi" ["course_name"]=&gt; string(31) "Step by Step Macintosh Training" [1]=&gt; string(31) "Step by Step Macintosh Training" ["unit_id"]=&gt; string(3) "231" [2]=&gt; string(3) "231" ["unit_quantity"]=&gt; string(1) "1" [3]=&gt; string(1) "1" } 
  array(8) { ["author_name"]=&gt; string(15) "William Merussi" [0]=&gt; string(15) "William Merussi" ["course_name"]=&gt; string(31) "Step by Step Macintosh Training" [1]=&gt; string(31) "Step by Step Macintosh Training" ["unit_id"]=&gt; string(3) "233" [2]=&gt; string(3) "233" ["unit_quantity"]=&gt; string(1) "1" [3]=&gt; string(1) "1" } 
  array(8) { ["author_name"]=&gt; string(10) "tuiuiu_dev" [0]=&gt; string(10) "tuiuiu_dev" ["course_name"]=&gt; string(32) "How to become a Powerful Speaker" [1]=&gt; string(32) "How to become a Powerful Speaker" ["unit_id"]=&gt; string(4) "1080" [2]=&gt; string(4) "1080" ["unit_quantity"]=&gt; string(1) "1" [3]=&gt; string(1) "1" } 
  array(8) { ["author_name"]=&gt; string(10) "tuiuiu_dev" [0]=&gt; string(10) "tuiuiu_dev" ["course_name"]=&gt; string(32) "How to become a Powerful Speaker" [1]=&gt; string(32) "How to become a Powerful Speaker" ["unit_id"]=&gt; string(4) "1084" [2]=&gt; string(4) "1084" ["unit_quantity"]=&gt; string(1) "1" [3]=&gt; string(1) "1" } 
  </code></pre>
  
  <p>Thank you for any help!</p>