Re: different operations on files than dirs

From: Date: Thu, 16 Nov 2000 22:41:06 +0000
Subject: Re: different operations on files than dirs
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-25764@lists.php.net to get a copy of this message
cool code Lawrence... For anyone following this post, i discovered a little detail about is_dir that I hadn't known before I implemented the original code i posted to this group... the CWD isn't necessarily the $DOCUMENT_ROOT of the script being executed... Basically, all I had to do to my original code was add: $handle=opendir($this->dirshow); chdir($handle); Hope this helps someone else... Thanks for all the replies. phool kevin@vcconcepts.com <Lawrence.Sheed@dfait-maeci.gc.ca> wrote in message news:4B0FC61A2044D31180A60000F810DF203C46C1@shngir01.shngi.dfait-maeci.gc.ca ... > function GetDirCount ($sPath) { > $handle=opendir ($sPath); > while ($file=readdir($handle)){ > $count++; > } > return ($count); > } > > > function Get_File_List($sPath) > global $dir_array,$file_array; > if(!$sPath) > $sPath = "."; > } > $dir_handle = opendir($sPath); > $count = $a = 0; > while($file = readdir($dir_handle)) { > if (is_dir ("/$sPath/$file") { > $dir_array [$count]= array($file,GetDirCount > ("$sPath/$file")); > $count++; > } > else { > $file_array [$a]= array($file,filesize > ("$sPath/$file"),date("F j Y h:i:s A", filemtime("$sPath/$file") > ) ); > > $a++; > } > > } > } > > $dir_array=array(); > $file_array=array(); > > Get_File_List ("."); > > > Files are listed in file_array > Directories are listed in dir_array > -----Original Message----- > From: Kevin Ferron [mailto:kevin_ferron@hotmail.com] > Sent: November 16, 2000 05:36 PM > To: php-general@lists.php.net > Subject: [PHP] different operations on files than dirs > > > I'm stuck.. variations on the following code is what I've been trying: > > $handle=opendir($this->dirshow); > while (false!==($file = readdir($handle))) { > if ($file != "." && $file != "..") { > if (is_dir($file) == 1) { > > STUFF I WANT TO HAPPEN IF ITS A DIR > } > > elseif (is_dir($file) == 0) { > IF ITS A FILE > } > > Thanks for your help. > > phool > > > > -- > 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 > > -- > 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 >

« previous php.general (#25764) next »