RE: [PHP] Create Array?? More

From: Date: Sun, 23 Sep 2001 07:53:52 +0000
Subject: RE: [PHP] Create Array?? More
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-68406@lists.php.net to get a copy of this message
> -----Original Message----- > From: KPortsmout@aol.com [mailto:KPortsmout@aol.com] > Sent: Sunday, 23 September 2001 16:46 > To: evan@coeus-group.com; php-general@lists.php.net > 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("\n<TD>%s</TD>%s<TD></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.</td><td>%s</TD>", $i, $MyContent[$i*2]); if( $i % 2){ // new line after each two entries echo "</tr><tr>\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

« previous php.general (#68406) next »