Paginate an array
<p><strong>I have an array $myarray;</strong>   I want to paginate the array content, here is what i am thinking of doing:</p>

<pre><code>//Find total number of rows
        $all_rs = $newArrayOfRows;
        $this-&gt;total_rows = count($all_rs);


        //Max number of pages
        $this-&gt;max_pages = ceil($this-&gt;total_rows / $this-&gt;rows_per_page );
        if ($this-&gt;links_per_page &gt; $this-&gt;max_pages) {
            $this-&gt;links_per_page = $this-&gt;max_pages;
        }


        //Check the page value just in case someone is trying to input an aribitrary value
        if ($this-&gt;page &gt; $this-&gt;max_pages || $this-&gt;page &lt;= 0) {
            $this-&gt;page = 1;
        }


        //Calculate Offset
        $this-&gt;offset = $this-&gt;rows_per_page * ($this-&gt;page - 1);


        //Fetch the required result set
</code></pre>

<p><strong>How do i join all this info in order to fetch from my initial array just the info i need for every single page?</strong> Ty very much</p>
