php - Find images with certain extensions recursively -


I am currently trying to create a script that has * .jpg / * .png extension in directories and subdirectories I will find the picture.

If any image is found with any of these extensions, then save it in an array with path, name, size, height and width.

So far I have this piece of code, which will be available to all files, but I do not know how to get only JPG / PGG images.

  class image check {public static function getDirectory ($ path = '.', $ Level = 0) {$ ignore = array ('cgi-bin', '.', '.. '); // Directories: Do not pay attention when indexing $ Dh = @opendir ($ path); // Open the directory at $ d headlined (wrong! == ($ file = readdir ($ dh)) // // Loop through directory (! In_array ($ file, $ ignore)) // // Check That this file is ignored $ spaces = str_repeat ('& amp; nbsp;', ($ level * 4)); // Just to add a spacing to the list, show the better // directory tree. If there is a directory of it (is_dir ("$ path / $ file")), // we have to continue reading it ... resonance "strong"; $ spaces $ file & lt; / strong & Gt; & lt; br / & gt; "; ImageCheck :: getDirectory ("$ path / $ file", ($ level + 1)); // Call this function again but on a new directory. // This function makes recursive} Else {resonant "$ spaces $ file 
; // Just print the file name}}} Monkey ($ dh); // Close the directory handle}}

I call this function in my template like this

  ImageCheck :: getDirectory ($ dir) ; Save many headaches and only PHP is built in a recursive search with a résox expression.     

If you are not familiar with working with objects, then how to iterate the response:

  & lt; Php foreach ($ Regex as $ name = & gt; $ Regex) {resonant "$ name \ n"; }? & Gt;  

Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -