Re: creating a text file

From: Date: Thu, 10 Apr 2003 15:10:08 +0000
Subject: Re: creating a text file
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-143353@lists.php.net to get a copy of this message
Tyler Durdin wrote:
Is there a way to make php create a text file that lists contents of a directory? This is what I use from shell: csh -c "ls *jpg > list.photos" I have a photo gallery that reads the images in a directory from a text file. I would like to eliminate the manual creation of that file. If
Try something like this: if ($dir = @opendir('/path/to/pics') {
    while (($file = readdir($dir)) !== false) {
        if(strpos($file, ".jpg")>0) {
	    $names[] = $file;
    	}
    }
    closedir($dir);
    sort($names); // optional
} HTH, Karsten

« previous php.general (#143353) next »