Re: Php & Directory structures
| From: | George Nicolae | Date: | Sat, 22 Dec 2001 18:15:04 +0000 |
| Subject: | Re: Php & Directory structures | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-78578@lists.php.net to get a copy of this message | ||
u can use the function
function GetDirArray($sPath)
{
//Load Directory Into Array
$handle=opendir($sPath);
while ($file = readdir($handle)) if(($file!=".")&($file!=".."))
$retVal[(isset($retVal))?count($retVal):0] = $file;
//Clean up and sort
closedir($handle);
sort($retVal);
return $retVal;
}
//and then
count($a=GetDirArray($sPath))
--
Best regards,
George Nicolae
IT Manager
___________________
X-Playin - Professional Web Design
www.x-playin.f2s.com
"Bogdan Stancescu" <mgv@fx.ro> wrote in message
news:3C24A75D.71950B0D@fx.ro...
> Just a suggestion: use exec("ls -1
root/articles/??_head.xml",$article_files) to
> find out the files -- then walk $article_files, parse the file and echo
whatever
> you please. :-)
>
> Bogdan
>
> Martin Hughes wrote:
>
> > Heya,
> >
> > Can PHP count the number of a certain ftile in a directory and then
print
> > the result to the screen? I have articles on my site that are in XML/XSL
> > format like:
> >
> > root/articles/00_head.xml
> > 00_body.xml
> > 01_head.xml
> > 01_body.xml
> > 02_head.xml
> > 02_body.xml
> > etc... (with appropriate XSL stylesheets too...)
> >
> > and I want to have a main "article page" with the head.xml info on it:
> >
> > Article 00:
> > By: <author>
> > Date: <whatever date>
> > Subject: <subject>
> >
> > and then a link to the article itself (which will be an XSL stylesheet
> > loading both the header info and the article body.xml).
> >
> > Can php count the number of articles etc in the dir and then
automatically
> > create the page? (or can anyone think of a better way of doing this????
:-))
> >
> > Cheers,
> >
> > Martin
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> > For additional commands, e-mail: php-general-help@lists.php.net
> > To contact the list administrators, e-mail: php-list-admin@lists.php.net
>