List all files in a diretory with glob (2)


/ Published in: PHP
Save to your folder(s)

List all files in a diretory with glob


Copy this code and paste it in your HTML
  1. //path to directory to scan
  2. $directory = "../images/team/harry/";
  3.  
  4. //get all image files with a .jpg extension.
  5. $images = glob($directory . "*.jpg");
  6.  
  7. //print each file name
  8. foreach($images as $image)
  9. {
  10. echo $image;
  11. }

URL: http://www.brightcherry.co.uk/scribbles/php-list-all-files-in-a-directory/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.