Reputation: 156
I've got a folder, and I've got a file. The file is test.csv
, but it could get overwritten and become pickle.csv
or sylvester.csv
or ethiopia.csv
, and so I need a way to open a single file in a folder which will always be a .csv
file with the name changing all the time. I don't want to have to constantly change the name in the source. I want it automatic.
I essentially want to be able to do something like this:
$handle=fopen(glob("/Applications/XAMPP/xamppfiles/htdocs/SITEPREVIEW/csv_drop_folder/*.csv")[0],"r")
BACK STORY: Someone is scp
-ing new content to a server and file names change, but function cannot.
Upvotes: 1
Views: 89
Reputation: 1679
Supposing you have one single csv file. Try using glob function:
$csv = glob("$yourDirectory/*.csv")[0];
Upvotes: 1