Advertisement
jargon

Fast_Cat_II

Apr 14th, 2022
1,590
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.58 KB | None | 0 0
  1. function fast_cat_ii( $path = '', $ext = array(), $type = __FILE__ )
  2. {
  3.     if( !is_array( $ext ) )
  4.     {
  5.         $ext = array( $ext );
  6.     }
  7.    
  8.     $cat = array();
  9.    
  10.     $iterator = new DirectoryIterator( dirname( $type ) );
  11.    
  12.     while( $iterator -> valid() )
  13.     {
  14.         $test = $iterator -> getFilename();
  15.        
  16.         foreach( $ext as $test_ext )
  17.         {
  18.             if( strtolower( substr( $test, -strlen( $ext ) ) ) === strtolower( $test_ext ) )
  19.             {
  20.                 $cat[] = $test -> getPathname();
  21.                 break;
  22.             }
  23.         }
  24.         $iterator -> next();
  25.     }
  26.    
  27.     natcasesort( $cat );
  28.     $cat = array_values( $cat );
  29.    
  30.     return $cat;
  31. }
  32.  
  33. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement