I am developing a news form where you can enter text and autor and submit it to a blog. After submit a file is created with the following naming convention: newsCounter_date.html
, e.g. 121_01_06_2018-093334.html
newsCounter
is a value which I increment after every submit, date
is the current date.
If someone loads the blog then all news entries are loaded via php, but first they are getting sorted so the latest news entry is on top. I am sorting like this:
$allFiles = array_diff(
scandir("news", SCANDIR_SORT_DESCENDING),
array('..', '.')
);
Everything worked fine, until I reached the 10. blog post, then something weird happened. Instead of the 10. post appearing at the top, it appeared somewhere at the bottom.
I noticed that the sorting does not work anymore, and it does behave completly else in my IDE than in windows. Look at this:
On Windows it goes from 0 -> 12, but in my NetBeans IDE it goes like this: 0 -> 10 -> 11 -> 12 -> 2 -> 3 -> 4 ... so I think NetBeans sort does work like SCANDIR_SORT
Hint: 1 is missing.
Is there another sort method than SCANDIR_SORT_DESCENDING
which works like
the windows sort?
How can I solve this problem?