Advertisement
jargon

Fast_Cat_II

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