regex - PHP Regular expression to find images beginning with _ -


I have a function that loads all the image files found in the WordPress Upload directory. I would like to modify it a bit so that it leaves on any image that starts with an underscore character, "_someimage.jpg" is skipped, while "someimage.jpg is not ...

< P> Here is the current function ....

  $ dir = 'wp-content / uploads' '$ url = get_bloginfo (' url ').' / Wp-content / uploads '' $ imgs = array (); if ($ dh = opendir ($ dir)) {while (($ file = readdir ($ dh)) == incorrect) {if (! Is_dir $ File) & amp; amp; amp; and & amp; amp; amp; preg_match ("/ {. JPEGIFIFGGGAARA", $ file}) {ARM_push ($ IGS, $ file);}} closed ($ dh);} and { $ Dir);}  

You modify your current regex Can you add a boolean or use expression (which I would recommend).

Modifying your current rezux:

  "/ ^ [^ _]. * \. (Bmp | jpeg | gif | string to detect underscores A simple expression will be:  
  strstr ($ file, '_') $ / i " 

)

Edit: And in fact you can use it:

  substr ($ file, 0, 1)! = '_'  

Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -