PHP Inverting content adding (sorting)

Posted by Adrian on Stack Overflow See other posts from Stack Overflow or by Adrian
Published on 2010-04-03T15:13:56Z Indexed on 2010/04/03 15:23 UTC
Read the original article Hit count: 334

Filed under:
|
|
|

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!

© Stack Overflow or respective owner

Related posts about php

Related posts about sort