I have a bunch of files for our website that have the months in the file name. However, the months are in sometimes full name, sometimes 3 letter abbreviation.
Now, what I want to do is to rename the file name (I can do that) to a consistant naming convention. I can get the year out of the string ($year = preg_replace(“/[^0-9]/”, ‘’, $mfiles); where $mfiles is the file name), but cannot figure out the best way to get the 3 letter month from the file name.
Ah, yes, more challenges than I want. But what you have is close. The year and month are there and the jist of the file type. Right now I just want to get the month out of the string. Oh, and sometimes the _ is there but more than not it is just a space.
In that case posting here a test array containing one of each of the possible formats is probably the only way you are going to get a robust and definitive solution on here.
$file_month will be an integer in the range 1-12 or FALSE if something other than a month string was detected.
$file_month will be a year in 4-digit format, with a range for 2-to-4 digit conversion of 1921-2020.