fork(39) download
  1. <?php
  2. echo 'GLOB'.PHP_EOL;
  3. chdir( '.' );
  4. $arquivos = glob("{*.php,*.jpg}", GLOB_BRACE);
  5. foreach($arquivos as $img) echo $img.PHP_EOL;
  6. echo PHP_EOL;
  7.  
  8. $types = array( 'php', 'jpg' );
  9.  
  10. echo 'DIR FUNCTIONS'.PHP_EOL;
  11. if ( $handle = opendir('.') ) {
  12. while ( $entry = readdir( $handle ) ) {
  13. $ext = strtolower( pathinfo( $entry, PATHINFO_EXTENSION) );
  14. if( in_array( $ext, $types ) ) echo $entry.PHP_EOL;
  15. }
  16. closedir($handle);
  17. }
  18. echo PHP_EOL;
  19.  
  20. echo 'DIRECTORY ITERATOR'.PHP_EOL;
  21. $path = '.';
  22. $dir = new DirectoryIterator($path);
  23. foreach ($dir as $fileInfo) {
  24. $ext = strtolower( $fileInfo->getExtension() );
  25. if( in_array( $ext, $types ) ) echo $fileInfo->getFilename().PHP_EOL;
  26. }
  27.  
Success #stdin #stdout 0.02s 52504KB
stdin
Standard input is empty
stdout
GLOB
prog.php

DIR FUNCTIONS
prog.php

DIRECTORY ITERATOR
prog.php