Fw: [PHP] dir to array? - SOLVED

2002-07-31 Thread Kevin Stone


- Original Message -
From: "Kevin Stone" <[EMAIL PROTECTED]>
To: "[EMAIL PROTECTED]" <'[EMAIL PROTECTED]'>
Sent: Wednesday, July 31, 2002 3:03 PM
Subject: Fw: [PHP] dir to array? - SOLVED


> *LOL*  I was just about to post an answer for you but it looks like you
got
> it figured out.  Since I hate to waste the post here you go.. for what
it's
> worth anyway.  :)
> -Kevin
> --
>
> I would recommend reading up on readdir() function.  There are some good
> examples in there.  Also you might want to browse the manual for some
> examples.
>
> http://www.php.net/manual/en/function.readdir.php
>
> // dircont (string [directory path])
> // Returns Array of filenames in the given directory.
> // Returns FALSE on error.
> function dircont($path)
> {
> $dir_array = array();
> if (false !== ($dir = opendir($path)))
> {
> while (false !== ($file = readdir($dir)))
> {
> if ($file != '.' && $file != '..')
> {
> $dir_array[] = $file;
> }
> }
> return $dir_array;
> }
> else
> {
> return false;
> }
> }
>
> // To print..
> $path = "/home/helpelf/helpelf-www/";
> echo "";
> print_r(dircont($path));
> echo "";
>
> -Kevin
>
>
> - Original Message -
> From: "Jas" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Wednesday, July 31, 2002 2:22 PM
> Subject: Re: [PHP] dir to array? - SOLVED
>
>
> > I got it fixed, thanks again.  Just in case anyone else needs help with
> this
> > type of item look at readdir() at http://www.php.net
> > Jas
> >
> > "Jason Wong" <[EMAIL PROTECTED]> wrote in message
> > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > > On Thursday 01 August 2002 03:00, Jas wrote:
> > > > Not sure why this isn't working, any help is appreciated.  I am
trying
> > to
> > > > read the files in a directory and place them into an array.  Here is
> the
> > > > code:
> > > >
> > > > /* Function to create array of directory contents */
> > > > function dCNTS($files) {
> > > >  $dir = opendir("/path/to/directory/");
> > > >   while($imgs = readdir($dir)) {
> > > >if (($imgs != ".") && ($imgs != "..")) {
> > > > $cnt[count($imgs)] = $cnt;
> > > >} else {
> > > > print "Cannot create array of files in directory!"; }
> > > >}
> > > >   closedir($dir);
> > > >  }
> > >
> > > HOW isn't it working?
> > >
> > > --
> > > Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
> > > Open Source Software Systems Integrators
> > > * Web Design & Hosting * Internet & Intranet Applications Development
*
> > >
> > > /*
> > > One person's error is another person's data.
> > > */
> > >
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] dir to array? - SOLVED

2002-07-31 Thread Jas

I got it fixed, thanks again.  Just in case anyone else needs help with this
type of item look at readdir() at http://www.php.net
Jas

"Jason Wong" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> On Thursday 01 August 2002 03:00, Jas wrote:
> > Not sure why this isn't working, any help is appreciated.  I am trying
to
> > read the files in a directory and place them into an array.  Here is the
> > code:
> >
> > /* Function to create array of directory contents */
> > function dCNTS($files) {
> >  $dir = opendir("/path/to/directory/");
> >   while($imgs = readdir($dir)) {
> >if (($imgs != ".") && ($imgs != "..")) {
> > $cnt[count($imgs)] = $cnt;
> >} else {
> > print "Cannot create array of files in directory!"; }
> >}
> >   closedir($dir);
> >  }
>
> HOW isn't it working?
>
> --
> Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
> Open Source Software Systems Integrators
> * Web Design & Hosting * Internet & Intranet Applications Development *
>
> /*
> One person's error is another person's data.
> */
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php