title: Filter php array and keep only oldest data on duplicate data
body: <p>I've an array in PHP that can have <strong>multiple same labels</strong>, but <strong>creation date</strong> for each one is different. I try to <strong>filter</strong> my array and <strong>keep only old created data when duplicates labels exists</strong> in my array.</p>
  <p>The array look like this :</p>
  <pre class="lang-php prettyprint-override"><code>$data = [
       [0] =&gt; Array
          (
              [label] =&gt; &quot;Same label&quot;
              [created] =&gt; &quot;15/01/2022&quot; //recent data
          )
       [1] =&gt; Array
          (
              [label] =&gt; &quot;Same label&quot;
              [created] =&gt; &quot;11/01/2022&quot; //oldest data to unset
          )
       [2] =&gt; Array
          (
              [label] =&gt; &quot;Label alone&quot;
              [created] =&gt; &quot;18/01/2022&quot;
          )
  ]
  
  </code></pre>
  <p>And have to be like this :</p>
  <pre class="lang-php prettyprint-override"><code>$data = [
       [0] =&gt; Array
          (
              [label] =&gt; &quot;Same label&quot;
              [created] =&gt; &quot;11/01/2022&quot;
          )
       [1] =&gt; Array
          (
              [label] =&gt; &quot;Label alone&quot;
              [created] =&gt; &quot;18/01/2022&quot;
          )
  ]
  
  </code></pre>
  <p>Actually, I've tried with an <code>array_search()</code> but <strong>process is long</strong> if they are a lot of data. <strong>I can remove duplicate data</strong> but I don't know <strong>how to filter by created date only on duplicate labels</strong> in my array...</p>
  <pre><code>$data = [];
  foreach ($prs as $pr) {
    $exist = array_search($pr-&gt;getLabel, array_column($data, 'label'), TRUE);
  
    if (!$exist){
      $data[] = [
            'label' =&gt; $pr-&gt;getLabel(),
            'created' =&gt; $pr-&gt;getCreationDate(),
      ];
    }
  }
  </code></pre>
  <p>I saw that there are also <code>array_filter()</code> function, <code>array_key_exists()</code> and other good functions.</p>
  <p>Can you help me please ?</p>
  <p>I'll add more info as I progress, but I can't show all page or processes (just example because they are confidential data).</p>
  <p>Thank you a lot for your help.</p>