Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Oct 9th, 2015, 11:49 PM   #1
darkranger85
Hobbyist Programmer
 
Join Date: Jan 2011
Posts: 115
Rep Power: 7 darkranger85 is on a distinguished road
Looking for a little help: Scanning all files and directories

Ok, first off, I do not want to be given a fully working script. I am trying to exercise my coding abilities.

I'm trying to write a script that will scan every file and directory on a domain and store them in arrays, the files along side their last modified timestamp.

Here is what I've put together so far. I know it's flawed and far from finished.

$results = scandir($_SERVER['DOCUMENT_ROOT']);
	$dirs = array();
	$files = array();

	function fileSort($data){

		if (is_dir($data)) {
			$dirs[] = $data;
		} else if (is_file($data)) {
			$files[] = $data;
			filemtime($data);
		}

		return array($dirs, $files);

	}//END fileSort

	function pathing($results){

		foreach ($results as $result) {
			
			if ($result === '.' OR $result === '..') {
				
			} else {				
				fileSort($result);			
			}//END if Statement		
			
		}//END foreach

		fileSort($dirs);	
		
	}

	pathing($results);

I appreciate any input!
__________________
"If builders built buildings the way programmers wrote programs, then the first woodpecker that came along wound destroy civilization." -Gerald Weinberg
darkranger85 is offline   Reply With Quote
Old Oct 12th, 2015, 2:20 AM   #2
pritaeas
mod_pritaeas
 
Join Date: May 2009
Location: The Netherlands
Posts: 251
Rep Power: 9 pritaeas is on a distinguished road
Re: Looking for a little help: Scanning all files and directories

It's a start, but if you're interested in a little more modern solution, have a look at this class:

http://php.net/directoryiterator
pritaeas is offline   Reply With Quote
Reply

Bookmarks

Tags
php

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Recursively rename some files name mail4mz Bash / Shell Scripting 1 Jul 11th, 2011 11:32 PM
How to store files/directories in different different directories!! anishkumarv Bash / Shell Scripting 0 Mar 23rd, 2011 5:49 PM
Delete specific Files using Cmd scripting jaacmmason Other Programming Languages 3 Apr 15th, 2010 2:28 PM
Can JSP Access .jar files? ssrun Java 2 May 29th, 2007 12:43 PM
copying files rwm C++ 8 Apr 26th, 2007 2:39 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 4:42 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC