function date_compare($a, $b)
{
$t1 = strtotime($a['lastEdit']);
$t2 = strtotime($b['lastEdit']);
return $t1 - $t2;
}
usort($container, 'date_compare');
$totalPages = floor($count/12);
$start = $page * 12 - 11;
$end = $page * 12;
$container = array_reverse($container);
$container = array_slice($container, $start, $end);
return $container;
My start doesn’t seem to affect the slice method. When I’m on page 2 for example, (start: 13 and end: 24), I still get a array(24) returned. What did I miss?
The 3rd parameter to
array_sliceis not actually “end”, but rather “length” — see the doc.So change
to
and
to
Note
$lenmight be off by one if you expected$endto not be inclusive.Edit:
Actually, it looks like you could just specify the length parameter as 11 as it looks fixed.