Hey guys.
I have some files on my web server and I need to search through their files name with a certain string. That string will change based upon the record that the loop is on (using a foreach loop to run through my array).
Right now, the files are named like such -- ESC-440_Paper_Bassalee.
Therotically, if I could get all of the file names in that specific folder to be converted to string names, that would be ideally. Then I could just explode the strings with the "_" delimiter and then search the arrays for the relationship.
Anyone have ANY idea how to handle this?
Thanks.
Searching File Name For String With PHP
Moderator: General Moderators
-
Shane.Jeffery
- Forum Newbie
- Posts: 1
- Joined: Sat Oct 25, 2008 5:41 pm
Re: Searching File Name For String With PHP
Not sure what you're asking here, but...
...might be what you're looking for. Although you may want to exclude files like ".", "..", and ".DS_Store".
Code: Select all
$array = array();
foreach( scandir( "/path/to/a/directory" ) as $filename )
$array[] = explode( "-", $filename );