Marcelo
Marcelo

Reputation: 157

Reversing order of globbed files

I am using the following code to include all of the files in the directory 'versions'

<?php
    foreach (glob("versions/*.php") as $filename)
    {
        include $filename;
    }
?>

This works well to show the files in the order like 1.1, 1.2, 1.2-1, 1.2-2, 1.3 and so on, but I'd like the order of the files to be reversed. Would this be possible in any way?

Upvotes: 2

Views: 91

Answers (1)

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 799100

foreach (array_reverse(glob("versions/*.php")) as $filename)

Upvotes: 2

Related Questions