title: Replace array keys using an array of values
body: <p>I'm currently working with a CSV file that I am converting into an array. However, I would like for my array keys to be the values of the first row. I'm looking for an easy way to get this done.</p>
  
  <pre><code>$newArray = [];
  $handle = fopen($file, "r");
  $firstRow = fgetcsv($handle, 5000, ",");
  while (false !== ($row = fgetcsv($handle, 5000, ','))) {
      $newArray[] = $row;
  }
  </code></pre>
  
  <p>Now, <code>$row</code> will have numeric array keys as is usual with arrays. However, I would like <code>$firstRow</code> to replace those keys. Can someone help me out?</p>
  
  <h3>Update</h3>
  
  <p>As requested, some example data.</p>
  
  <pre><code>"name","age","active","date_added"
  "John Doe","24","yes","2018-01-02"
  "Jane Doe","41","yes","2018-01-03"
  "Joe Doe","28","yes","2018-01-04"
  "Janett Doe","30","no","2018-01-05"
  </code></pre>
  
  <p>Currently, <code>var_dump($row)</code> will output:</p>
  
  <pre><code>array(4) {
      [0]=&gt; "John Doe"
      [1]=&gt; "24"
      [2]=&gt; "yes"
      [3]=&gt; "2018-01-02"
  }
  </code></pre>
  
  <p>The expected result:</p>
  
  <pre><code>array(4) {
      ['name']=&gt; "John Doe"
      ['age']=&gt; "24"
      ['active']=&gt; "yes"
      ['date_added']=&gt; "2018-01-02"
  }
  </code></pre>