RE: [PHP] readfile
| From: | WILSON, Nick | Date: | Wed, 12 Jul 2000 00:21:08 +0000 |
| Subject: | RE: [PHP] readfile | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-6053@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Daniel Gustafsson [mailto:cloaked@hem.passagen.se]
> Sent: Wednesday, 12 July 2000 0:15
> To: php-general@lists.php.net
> Subject: Re: [PHP] readfile
>
>
> At 10:02 AM 7/11/00 -0400, you wrote:
> >While it works, it's kinda clunky. Shortcuts?
>
> <?
> for ($x=0; 1; $x++)
> {
> $memo='memo'.$x.'.txt';
> if ( !file_exists($memo) ) break;
> readfile($memo);
> }
> ?>
>
> As a democoder I can only say this: never render anything in multiple
> passes when you can do it in just one ;)
Yes but always look at the code to ensure it actually does what one
thinks it's going to do. The whole point of the slightly clunky code
was to find the files and then read from them in 'reverse' order which
seems to have been overlooked here ?
If it doesn't matter to them then fine though. For what it's worth,
something
like
/* Determine number of memo*.txt files */
for ($memno=1, file_exists('memo'.$memno.'.txt'), $memno++) {}
$memno--;
/* Read each memo file in reverse order */
for ($count=$memno, $count > 0, $count--) {
readfile('memo'.$count.'.txt');
*This isn't tested but should be close*