php - Sort by part of filename
319
I have a$inhalte = glob("*.jpg");
listing pictures in a directory. Those files look like this
Constant1-Constant2-Input-ToBeSorted1-Date1.jpg
Constant1-Constant2-Output-ToBeSorted2-Date2.jpg
Constant1-Constant2-Input-ToBeSorted3-Date3.jpg
Constant1-Constant2-Output-ToBeSorted4-Date4.jpg
...
They should be sorted byToBeSorted
alphabetically. Sorting them by name a/descendingly does not work, as theInput/Output
interferes.
How do I accomplish that?
Answer
Solution:
strstr provides the string behind 'ToBeSorted' and helps to make a simple comparison for usort().