обрезка массива
function cutTheArray($array, $start, $length = null) { $count = count($array); if($start < 0) { $start = $count + $start; } if($length !== null) { if($length < 0) { $length = $count - $start + $length; } return array_slice($array, $start, $length); } else { return array_slice($array, $start); } } cutTheArray([1, 2, 3, 4, 5, 6], 2, 1); // [3] cutTheArray([1, 2, 3, 4, 5, 6], 0, 3); // [1, 2, 3] cutTheArray([1, 2, 3, 4, 5, 6], -2); // [5, 6]