shadowayex Posted December 4, 2008 Share Posted December 4, 2008 Well, I use glob() to find files for a file access system I'm using. I use a Debian distribution for my server and it makes backup files of each one of my files. The glob() finds these so the array has a regular file, then a back up file ending in a tilde (~). For example, it could have:files[0] filename.php -> files[1] filename.php~Or something along those lines. I want to know how I can have PHP delete and/or ignore the files with a tilde (~) . I figured a regular expression of some kind to do it, but I don't know which or anything. Any ideas? Link to comment Share on other sites More sharing options...
Synook Posted December 5, 2008 Share Posted December 5, 2008 if (substr($filename, -1) == "~") unlink($filename); Link to comment Share on other sites More sharing options...
shadowayex Posted December 5, 2008 Author Share Posted December 5, 2008 Woots!!! That did it! Thank you so much! Now I just gotta get it to recognize folders from files and different file types. But I'm one step closer to where I want to be. Thank you. Link to comment Share on other sites More sharing options...
Synook Posted December 5, 2008 Share Posted December 5, 2008 is_dir() tells you whether it is a directory. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.