title: PHP - Change value if same and multiple in array exept the first
body: <p>I'm trying to change values of an array if one af the value is several times into and change duplicate values exept the first.</p>
  
  <p>I have this array:</p>
  
  <pre><code>array (size=6)
    0 =&gt; 
      array (size=3)
        'id' =&gt; int 1
        'data-time-start' =&gt; int 0
        'data-time-end' =&gt; int 5
    1 =&gt; 
      array (size=3)
        'id' =&gt; int 2
        'data-time-start' =&gt; int 6
        'data-time-end' =&gt; int 10
    2 =&gt; 
      array (size=3)
        'id' =&gt; int 1
        'data-time-start' =&gt; int 11
        'data-time-end' =&gt; int 15
    3 =&gt; 
      array (size=3)
        'id' =&gt; int 3
        'data-time-start' =&gt; int 16
        'data-time-end' =&gt; int 20
    4 =&gt; 
      array (size=3)
        'id' =&gt; int 4
        'data-time-start' =&gt; int 21
        'data-time-end' =&gt; int 25
    5 =&gt; 
      array (size=3)
        'id' =&gt; int 3
        'data-time-start' =&gt; int 30
        'data-time-end' =&gt; int 35
    6 =&gt; 
      array (size=3)
        'id' =&gt; int 3
        'data-time-start' =&gt; int 40
        'data-time-end' =&gt; int 45
  </code></pre>
  
  <p>In this example I have two times <code>'id' = int 1</code> and three times <code>'id' = int 3</code> .
  What I would like to do is to keep the first ID but set other duplicate IDs to <code>NULL</code> and return an array like this:</p>
  
  <pre><code> array (size=6)
    0 =&gt; 
      array (size=3)
        'id' =&gt; int 1
        'data-time-start' =&gt; int 0
        'data-time-end' =&gt; int 5
    1 =&gt; 
      array (size=3)
        'id' =&gt; int 2
        'data-time-start' =&gt; int 6
        'data-time-end' =&gt; int 10
    2 =&gt; 
      array (size=3)
        'id' =&gt; null
        'data-time-start' =&gt; int 11
        'data-time-end' =&gt; int 15
    3 =&gt; 
      array (size=3)
        'id' =&gt; int 3
        'data-time-start' =&gt; int 16
        'data-time-end' =&gt; int 20
    4 =&gt; 
      array (size=3)
        'id' =&gt; int 4
        'data-time-start' =&gt; int 21
        'data-time-end' =&gt; int 25
    5 =&gt; 
      array (size=3)
        'id' =&gt; null
        'data-time-start' =&gt; int 30
        'data-time-end' =&gt; int 35
    6 =&gt; 
      array (size=3)
        'id' =&gt; null
        'data-time-start' =&gt; int 40
        'data-time-end' =&gt; int 45
  </code></pre>
  
  <p>I'm not an expert in php ...</p>
  
  <p><strong>EDIT 1 :</strong></p>
  
  <p>Tried with that:</p>
  
  <pre><code>function setNulForDuplicatesInArray($arr, $keyToFind)
      {
          $newArr = array();
          for ($i = 0; $i &lt; sizeof($arr); $i++) {
              if (in_array($arr[$i], $newArr))
                  $newArr[$i][$keyToFind] = null;
              else
                  $newArr[] = $arr[$i];
          }
          return $newArr;
      }
  
  var_dump(setNulForDuplicatesInArray($arr, 'id'))
  </code></pre>
  
  <p>But nothing happened</p>
  
  <p>Thanks for your help !</p>