title: I have a below array with some same keys with different values. How can I combine same keys values with that key in PHP? I am using WAMP, Codeigniter
body: <p>I am getting these data from importing CSV file. In CSV file I have 1st column is Years and all other columns are Make. I am using csvreader library for parsing data from CSV file.</p>
  
  <p>My CSVReader Library.</p>
  
  <pre><code>class CI_Csvreader {
  
      var $fields;        /** columns names retrieved after parsing */  
      var $separator = ',';    /** separator used to explode each line */  
  
      /** 
       * Parse a text containing CSV formatted data. 
       * 
       * @access    public 
       * @param    string 
       * @return    array 
       */  
      function parse_text($p_Text) {  
              $lines = explode("\n", $p_Text);  
              return $this-&gt;parse_lines($lines);  
      }  
  
      /** 
       * Parse a file containing CSV formatted data. 
       * 
       * @access    public 
       * @param    string 
       * @return    array 
       */  
      function parse_file($p_Filepath) {  
              $lines = file($p_Filepath);  
              return $this-&gt;parse_lines($lines);  
      }  
      /** 
       * Parse an array of text lines containing CSV formatted data. 
       * 
       * @access    public 
       * @param    array 
       * @return    array 
       */  
      function parse_lines($p_CSVLines) {  
              $content = FALSE;  
              foreach( $p_CSVLines as $line_num =&gt; $line ) {  
                      if( $line != '' ) { // skip empty lines  
                              $elements = explode($this-&gt;separator, $line);  
  
                              if( !is_array($content) ) { // the first line contains fields names  
                                      $this-&gt;fields = $elements;  
                                      $content = array();  
                              } else {  
                                      $item = array();  
                                      foreach( $this-&gt;fields as $id =&gt; $field ) {  
                                              if( isset($elements[$id]) ) {  
                                                      $item[$field] = $elements[$id];  
                                              }  
                                      }  
                                      $content[] = $item;  
                              }  
                      }  
              }  
              return $content;  
      }
  </code></pre>
  
  <p>My CSV file data =></p>
  
  <pre><code>Years   Make    Make    Make
  2001    Acura   Honda   Toyota
  2002    Acura   Honda   
  2003    Acura           Toyota
  2004                          
  </code></pre>
  
  <p>In above file Years and Make data in Excel/CSV sheet can be changed later.</p>
  
  <p>My output is an array.=></p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [Years] =&gt; 2001
              [Make] =&gt; Acura
              [Make] =&gt; Honda
              [Make] =&gt; Toyota
          )
  
      [1] =&gt; Array
          (
              [Years] =&gt; 2002
              [Make] =&gt; Acura
              [Make] =&gt; Honda
              [Make] =&gt; 
          )
      [2] =&gt; Array
          (
              [Years] =&gt; 2003
              [Make] =&gt; Acura
              [Make] =&gt; 
              [Make] =&gt; Toyota
          )
      [3] =&gt; Array
          (
              [Years] =&gt; 2004
              [Make] =&gt; 
              [Make] =&gt; 
              [Make] =&gt; 
          )
  )
  </code></pre>
  
  <p>I want my result array like this =>
  I want to keep null values.</p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [Years] =&gt; 2001
              [Make] =&gt; Array(
                                [0]=&gt;Acura
                                [1]=&gt;Honda
                                [2]=&gt;Toyota
                             )
          )
  
      [1] =&gt; Array
          (
              [Years] =&gt; 2002
              [Make] =&gt; Array(
                                [0]=&gt;Acura
                                [1]=&gt;Honda
                                [2]=&gt;
                             )
          )
      [2] =&gt; Array
          (
              [Years] =&gt; 2003
              [Make] =&gt; Array(
                                [0]=&gt;Acura
                                [1]=&gt;
                                [2]=&gt;Toyota
                             )
          )
      [3] =&gt; Array
          (
              [Years] =&gt; 2004
              [Make] =&gt; Array(
                                [0]=&gt;
                                [1]=&gt;
                                [2]=&gt;
                             )
          )
  )
  </code></pre>
  
  <p>Also please show me how to get result without null values.</p>
  
  <p>If there any other way to get data from CSV file in my desired format that would be ok.</p>
  
  <p>Can anyone please help me. Thank you very much.</p>