title: PHP - File to Associative Array with 1 key and two values attached
body: <p>I have a text file that contains:</p>
  
  <pre><code>email:number1:number2    
  email:number1:number2    
  email:number1:number2    
  email:number1:number2   
  </code></pre>
  
  <p>What i need to do is store these in an associative array where the email is the key and the numbers are values.</p>
  
  <p>How can i do this with PHP?</p>
  
  <p>Below is my attempt so far</p>
  
  <pre><code>&lt;?php
  
  // file path 
  $file = 'orderdata'; 
  // open the file and get the resource handle with errors suppressed 
  $handle = @fopen($file,'r'); 
  // array to hold our values 
  $params = array(); 
  if($handle) 
  { 
  // if handle is there then file was read successfully 
  // as long as we aren't at the end of the file 
     while(!feof($handle)) 
     { 
         $line = fgets($handle); 
         $temp = explode(':',$line); 
         $params[$temp[0]] = $temp[1]; 
     } 
     fclose($handle); 
  } 
  
  function search_array ( array $array, $term )
  {
      foreach ( $array as $key =&gt; $value )
          if ( stripos( $value, $term ) !== false )
              return $key;
  
      return false;
  }
  
  ?&gt;
  </code></pre>