Reputation: 71
I have this script to access all the xml files in a folder. But how would I specify a directory inside the glob ?
Here's my code :-
foreach (glob("*.xml*") as $filename) {
echo $filename."<br />";
}
Upvotes: 0
Views: 31
Reputation: 217
You can add the directory in this way :-
$dir="dirname/";
foreach (glob("$dir*.xml*") as $filename) {
echo $filename."<br />";
}
Notice :- When you echo the filename, the directory would come attached to it. So for instance the filename is example.txt, then the output will be dirname/output.txt. You can then use explode to remoe the dir name.
Upvotes: 1