Re: Looping through directories?
| From: | Chris Wesley | Date: | Wed, 08 Jan 2003 16:33:13 +0000 |
| Subject: | Re: Looping through directories? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-130776@lists.php.net to get a copy of this message | ||
On Wed, 8 Jan 2003, Jeff Lewis wrote:
> pattern for the name if the indexes, I assume I need to create an array
> holding the directory name and the associated index file name like so
> $dirs = array("Sports" => "spindex.xml", "Business News" =>
> "business.xml") etc
>
> Now, I need help with the loop to whip through each directory. Would I
> do a foreach on the array I just created? Any help would be greatly
> appreciated. I need to be able to access both the directory name and
> index name.
foreach() would work for you ...
foreach( $dirs as $dirName => $indexName ){
$indexPath = "${dirName}/${indexName}";
$fh = fopen( $indexPath, "r" );
// ...
fclose( $fh );
// I'm just guessing; do whatever you want in this loop
}
hth,
~Chris