Assoc Arrays

From: David (biffta_at_hotmail.com)
Date: 01/30/04


Date: 30 Jan 2004 10:13:17 -0800

I have a script which retrives a list of files then reads the first
two lines of each one of these files.
Code:
function retrieve_headers($username)
{
   if(!file_exists('c:/'.$username))
      return false;
   $directory = opendir("c:/$username//");
   $ary=array();
   while($file = readdir($directory))
   {
      if(!(is_dir($file) || ($file=='.') || ($file =='..')))
      {
         $fp = fopen("c:/$username/$file", "r");
         $recip = fgets($fp);
         $sender = fgets($fp);
         array_push($ary,"$recip$sender");
         fclose($fp);
      }
   }
   return $ary;
}
The idea is I want an array with $recip as the key and $sender as the
value.
Unfortunently the above code outputs an array like this:
Code:
0 => foo bar
1 => foo bar
2 => foo bar
Any idea how I could go about this?



Relevant Pages