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_header s($username)
{
if(!file_exists ('c:/'.$username))
return false;
$directory = opendir("c:/$username//");
$ary=array();
while($file = readdir($direct ory))
{
if(!(is_dir($fi le) || ($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?
two lines of each one of these files.
Code:
function retrieve_header s($username)
{
if(!file_exists ('c:/'.$username))
return false;
$directory = opendir("c:/$username//");
$ary=array();
while($file = readdir($direct ory))
{
if(!(is_dir($fi le) || ($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?
Comment