could you try to replace cycle with [array_slice](http://php.net/manual/ru/function.array-slice.php)?