CoderZone.org

Category: >> PHP Code >> Include All Files In A Directory Bookmark and Share

<< lastnext >>

Snippet Name: Include All Files In A Directory

Description: This function will include all files from a specified directory. You can filter files by extension (uses .php for default).

Also see:
» Active Directory - Reading the Use...
» Javascript Include - allows dynami...
» Simple directory viewer / browser
» Read a web page directly in to a s...
» Recursive Directory Browser
» Create an array from the contents ...
» Get A Directory Listing Of Specifi...
» Check If A Directory Allows File C...
» Saving Remote Images With PHP
» More File Type Detection in PHP
» Get Current Page URL
» Get Current Directory Name
» Measure script run time
» Random Image from Directory
» Write to File example
» Get oldest file in directory
» Check if a file exists
» Recursive Directory Browser
» List files in directory
» Export table to Excel or MS Word f...
» Test If File Is Included
» Protect Writable Directory
» Directory Listing #2
» Directory Listing
» Count lines in file
» Copy File From Server
» Remove All Files An A Given Direct...
» Calculate File/Folder Size In A Di...

Comment: (none)

Author: CoderZone
Language: PHP
Highlight Mode: PHP
Last Modified: March 16th, 2009

function include_from($dir, $ext='php'){
 
	$opened_dir = opendir($dir);
 
	while ($element=readdir($opened_dir)){
	   $fext=substr($element,strlen($ext)*-1);
	   if(($element!='.') && ($element!='..') && ($fext==$ext)){
		  include($dir.$element);
	   }
	}
	closedir($opened_dir);
}
 
 
There haven't been any comments added for this snippet yet. You may add one if you like.  Add a comment 
© coderzone.org | users online: 27