I am trying to open a text file of user names and write it to a .htpassGroup file.
The list of user names needs to be on the same line for the .htpassGroup file to work. I can write to the file just fine, but when I do I get this output:
username
another_username
etc..
and it needs to be:
username another_username etc..
Here is what my code looks like:
-Thanks in advance for any help and ideas.
###################################
<?
$masterPass = "employeeUserNames.txt"; //line delimited list of usernames
if(!($openMasterPass = fopen($masterPass, "r"))){
echo "Can't open $masterPass";
}
else{
$countFile = file($masterPass);
for($i=0; $i <= count($countFile); $i++){
$line = fgetss($openMasterPass, 4096);
$userInfo = explode("\n", $line);
$passwdFile = ".htEmployeeGroup";
if(!($openPasswdFile = fopen($passwdFile, "w"))){
echo "Can't open $passwdFile";
}
else{
$fileData .= " " . $countFile[$i];
}
}
$data = "employee: " . $fileData;
echo "Finished writing file\n\n";
echo "$fileData";
fputs($openPasswdFile, $fileData);
fclose($openPasswdFile);
fclose($openMasterPass);
}
?>
###########################