Include files from a directory - Php

filesfromdir

Snippet Code


  
Rate this page :
  [ 0 votes]

This function is used to include all files from a directory you can also filter the files by mentioninig the extension of a file

function include_from($dir, $ext='js'){ $opened_dir = opendir($dir); while ($element=readdir($opened_dir)){ $fext=substr($element,strlen($ext)*-1); if(($element!='.') amp&($element!='..') amp&($fext==$ext)){ include($dir.$element); } } closedir($opened_dir); }

Tags


Ask Questions

Ask Question