Location: PHPKode > projects > Easy Music Box > list.php
<?php

$limit = 10; //set number of items in page
if (isset($_GET['p'])) {
    $page = $_GET['p'];
    $array_num = $limit * ($page-1);
}
else {
      $page = 1;
      $array_num = 0;
}

$rec = new browse ('upload/');
$file_array = $rec->recursive('upload/');
//show alphabetical order
if (isset($_GET['act']) && $_GET['act'] == 'sort') {
    function sort_name($a, $b) {
             if ($a[2] == $b[2]) return 0;
             return ($a[2] < $b[2]) ? -1 : 1;
    }
    usort($file_array, 'sort_name');
}
//show latest files
elseif (isset($_GET['act']) && $_GET['act'] == 'new') {
    function sort_date($a, $b) {
             if ($a[1] == $b[1]) return 0;
             return ($a[1] < $b[1]) ? 1 : -1;
    }
    usort($file_array, 'sort_date');
}
//paginate
$rec->paginate_array($file_array,$limit,$array_num,$page,'new');
?>
Return current item: Easy Music Box