Re: [PHP] Create Array?? More

2001-09-23 Thread KPortsmout

Ok, 

Thanks for the input, unfortunately it didn't help me solve my overall 
problem, so I will post that and see if anyone has any suggestions...

I am basically displaying the Usernames from a .htpasswd file like this...

$File=$Path$Directory1/.htpasswd;
$fd = fopen ($File, r);
$Content = fread ($fd, filesize ($File));
$Content=ereg_replace (\n,:, $Content);
// Explode the file using : as seperator
$MyContent = explode (:, $Content);
// Count it up
$LoU = count($MyContent)-1;
// Close the File
fclose($fd);

for ($a=0; $a  $LoU; $a+=2)
{
printf(\nTD%s/TD%sTD/TD, $MyContent[$a], $MyContent[$a+=2]);
}

This is working perfectly, but what I would like to do is display a number 
next to each one, at the moment it displays...

UserName1   UserName2
UserName3   UserName4

What I would like it to do is

1. UserName1   2. UserName2
3. UserName3   4. UserName4

I cannot figure a way to use $a because it has to skip by 2 in order not to 
display the encrypted passwords..any suggestions???

TIA
Ade

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Create Array?? More

2001-09-23 Thread Andrew Braund

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
 Sent: Sunday, 23 September 2001 16:46
 To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Subject: Re: [PHP] Create Array?? More
 
 
 Ok, 
 
 Thanks for the input, unfortunately it didn't help me solve my overall 
 problem, so I will post that and see if anyone has any suggestions...
 
 I am basically displaying the Usernames from a .htpasswd file like this...
 
 $File=$Path$Directory1/.htpasswd;
 $fd = fopen ($File, r);
 $Content = fread ($fd, filesize ($File));
 $Content=ereg_replace (\n,:, $Content);
 // Explode the file using : as seperator
 $MyContent = explode (:, $Content);
 // Count it up
 $LoU = count($MyContent)-1;
 // Close the File
 fclose($fd);
 
 for ($a=0; $a  $LoU; $a+=2)
 {
 printf(\nTD%s/TD%sTD/TD, $MyContent[$a], $MyContent[$a+=2]);
 }
 
 This is working perfectly, 

perhaps not for odd numbers of users?

Try; (untested!)

echo tr\n;
for ($i=0; $i*2  $LoU; $i++){
   printf(td%d./tdtd%s/TD, $i, $MyContent[$i*2]);
   if( $i % 2){ // new line after each two entries
echo /trtr\n;
   }
}
echo /tr\n;


but what I would like to do is display a number 
 next to each one, at the moment it displays...
 
 UserName1   UserName2
 UserName3   UserName4
 
 What I would like it to do is
 
 1. UserName1   2. UserName2
 3. UserName3   4. UserName4
 
 I cannot figure a way to use $a because it has to skip by 2 in order not to 
 display the encrypted passwords..any suggestions???
 
 TIA
 Ade


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]