How to do pagination from multiple array and calculate the total?
<p>I have an array that present the data will be use to display as paganation.</p>

<pre><code>$display_array = Array (
              [0] =&gt; Array
                  (
                  [0] =&gt; 1
                  [1] =&gt; 2
                  [2] =&gt; 5
                  [3] =&gt; 5
                  )

              [1] =&gt; Array
                  (
                  [0] =&gt; 1
                  [1] =&gt; 2
                  [2] =&gt; 5
                  [3] =&gt; 5
                  )

              [2] =&gt; Array
                  (
                  [0] =&gt; 1
                  [1] =&gt; 2
                  )

              [3] =&gt; Array
                  (
                  [0] =&gt; 1
                  [1] =&gt; 2
                  )

            )
</code></pre>

<p>I WANT DO A PAGANATION GET THE EXPECTED RESULT LIKE THIS:</p>

<p>IF I defined $show_per_page = <code>2</code>;</p>

<p>call paganation($display_array,1);//page 1 firstpage OUTPUT :</p>

<pre><code>1
2
</code></pre>

<p>call  paganation($display_array,2);//next page 2 OUTPUT :</p>

<pre><code>    5
    5
  Total:13 // total appear here 


....//next page n
</code></pre>

<p>IF I defined $show_per_page = <code>3</code>;</p>

<p>paganation($display_array,1);//page 1 firstpage OUTPUT: </p>

<pre><code>   1
   2
   5
</code></pre>

<p>paganation($display_array,2);//next page 2 OUTPUT :</p>

<pre><code>  5
  Total:13//Now total appear here
  1
  2
</code></pre>

<p>paganation($display_array,3);//next page 3 OUTPUT :</p>

<pre><code> 5
 5
 Total:10 // total appear here 
 1
</code></pre>

<p>IF I defined $show_per_page = <code>12</code>;
call paganation($display_array,1);//page 1 firstpage OUTPUT :</p>

<pre><code>1
2
5
5
total:13 // total here
1
2
5
5
total:13 // total here
1
2
total:3 //total
1
2
total:3 //total
</code></pre>

<p>People here have any idea?</p>
