return array range
<pre><code>function GetImages($orderByDate, $start, $end)
{

$container = array();

if ($handle = opendir('uploads')) 
{
    while (false !== ($file = readdir($handle))) 
    {
        if ($file != "." &amp;&amp; $file != "..") 
        {
            $filename = 'uploads/' . $file;
            $lastEdit = date("F d Y H:i:s.", filemtime($filename));

            $image = array(
                'fileName' =&gt; $file,
                'lastEdit' =&gt; $lastEdit
            );

            array_push($container, $image);
        }
    }

    closedir($handle);
} 

if($orderByDate)
{
    function date_compare($a, $b)
    {
        $t1 = strtotime($a['lastEdit']);
        $t2 = strtotime($b['lastEdit']);
        return $t1 - $t2;
    }    
    usort($container, 'date_compare');
}

if(isset($start) &amp;&amp; isset($end))
{
    array_slice($container, $start, $end);
}

return $container;

}

echo '&lt;pre&gt;';
var_dump(GetImages(true, 0, 5));
echo '&lt;/pre&gt;';
</code></pre>

<p>Isnt <code>slice</code> the way to go here? Even if i pass a start and an end value, i still get all the records from the array. Thanks</p>
