fopen() question

From: Date: Fri, 28 Feb 2003 21:23:18 +0000
Subject: fopen() question
Groups: php.mirrors 
Request: Send a blank email to php-mirrors+get-15958@lists.php.net to get a copy of this message
I want to display all like named sequencial files without duplicating the information manually and only produce code for the files present. I think I have narrowed it down to two possiblities... fopen doesn't work with strings inside a for loop or there is something about the string I am producing that fopen balks on. What am I doing wrong? If I eliminate the for loop and have $i=1 everything works fine. Handcoding a single path and file into the fopen statement also works. <html> <body> <? $bcode = "<img src=\""; $path = "http://www.angelfire.com/rpg/scottrider/backgrounds/"; $file = "bg"; $ext=".jpg"; $ecode= "\">\n"; for($i = 1; $i < 10; ++$i) { $tnumber = "".sprintf("%02d",$i).""; $tfile = "".$path.$file.$tnumber.$ext.""; $nfile = @fopen("$tfile","r"); if($nfile) { print $bcode.$tfile.$ecode."<br>\n"; } } ?> </body> </html>

« previous php.mirrors (#15958) next »