Sorting
Posted: Thu Aug 12, 2010 11:14 am
Anyone got any ideas why this would display the first of $files, then the tenth, then the second, thrid and fourth etc. instead of the first, second, third, fourth fifth etc.?
Code: Select all
<?php function xfunction($page = 1, $num_posts = 5) {
$start = (($page - 1) * $num_posts);
$path = "content/posts/";
$files = glob("" . $path . "*.txt");
if ($files) {
rsort($files);
$files = array_slice($files, $start, $num_posts);
foreach ($files as $file) {
print("\n<article>");
include($file);
print("</article>\n");
}
} else {
echo "Somthing's Missing? Maybe you need to <a href='install.php'>Install?</a>";
}
} ?>