PHP Inverting content adding (sorting)
- by Adrian
Hello,
I have this code which will include "template.php" file from inside each of these folders: "content/templates/id1", "content/templates/id2", "content/templates/id3" etc. etc.
$page_file = basename(__FILE__, ".php");
require("content/" . $page_file . "/content.php");
$iterator = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($page_path),
RecursiveIteratorIterator::SELF_FIRST);
foreach($iterator as $file) {
if($file->isDir()) {
include strtoupper($file . '/template.php');
}
}
This code works pretty well, the problem is I want to inverse the content adding, meaning that I want first "content/templates/id9/template.php" included before "id8/template.php" and so on till the first..
How can I do this by modifying the code above?
A million thanks!