public function paginate($maxPerPage, $initialPage = 1, $key = null)
    {
        $result = [];
        $page = $initialPage;
        $array = $this->array;

        if ($maxPerPage <= 0) {
            return $result;
        }

        if (is_null($key) === false) {
            $array = $this->get($key);
        }

        $arrCount = count($array);

        for ($offset = 0; $offset < $arrCount;) {
            $slice = array_slice($array, $offset, $maxPerPage, true);
            $result[$page] = $slice;

            ++$page;
            $offset += count($slice);
        }

        return $result;
    }
public function paginate($maxPerPage, $initialPage = 1, $key = null)
    {
        $result = [];
        $page = $initialPage;
        $array = $this->array;

        if ($maxPerPage <= 0) {
            return $result;
        }

        if (is_null($key) === false) {
            $array = $this->get($key);
        }

        $arrCount = count($array);

        for ($offset = 0; $offset < $arrCount;) {
            $slice = array_slice($array, $offset, $maxPerPage, true);
            $result[$page] = $slice;

            ++$page;
            $offset += count($slice);
        }

        return $result;
    }
public function paginate ( $ maxPerPage , $ initialPage = 1 , $ key = null ) { $ result = [ ] ; $ page = $ initialPage ; $ array = $ this -> array ; if ( $ maxPerPage <= 0 ) { return $ result ; } if ( is_null ( $ key ) === false ) { $ array = $ this -> get ( $ key ) ; } $ arrCount = count ( $ array ) ; for ( $ offset = 0 ; $ offset < $ arrCount ; ) { $ slice = array_slice ( $ array , $ offset , $ maxPerPage , true ) ; $ result [ $ page ] = $ slice ; ++ $ page ; $ offset += count ( $ slice ) ; } return $ result ; }
Paginates the array.

@param int    $maxPerPage  Max items per page. If this value is minor than 1 the result will be an empty array
@param int    $initialPage Initial page. Page 1 by default
@param string $key         Element to paginate using "dot" notation

@return array A list of pages with an array of elements associated with each page
Paginates the array .