I have a folder containing php files from 1-25 each titled 1.php
2.php
etc.
I am wanting to echo the contents of each file in an array on a page using php in a descending order.
The problem I am having is that it is currently outputting in reverse order, when it gets to 10, it will then put 11 next to 1. This is not the logical system how a human would interpret.
I have been looking at this: http://php.net/manual/en/array.sorting.php
and I have tried arsort
, krsort
, natcasesort
and rsort
with little success to logically ordering my array after ten in a descending order starting at highest number first.
The full code is as follows:
$articles = glob("$_SERVER[DOCUMENT_ROOT]/assets/news/overview/*.php");
if(count($articles)) {
rsort($articles);
foreach($articles as $article) {
$article = basename($article);
include("$_SERVER[DOCUMENT_ROOT]/assets/news/overview/$article");
}
}
else {
echo "Sorry, no articles.";
}
Can anyone help me out with finishing this php script off? Thank you!