grouing array elements with given number in php : grouing array elements with given number in php.<br>
How to group array elements using php ?
i have the following array

    array (size=10)
       0 => int 1
       1 => int 2
       2 => int 3
       3 => int 4
       4 => int 5
       5 => int 6
       6 => int 7
       7 => int 8
       8 => int 9
       9 => int 10
i need group this array following model

    0 => 
    array (size=3)
       0 => int 1
       1 => int 2
       2 => int 3
    1 => 
     array (size=3)
       0 => int 4
       1 => int 5
       2 => int 6
    2 => 
      array (size=3)
        0 => int 7
        1 => int 8
        2 => int 9
    3 => 
      array (size=3)
        0 => int 10

How can i do this?<br>
i tried following code.

    $arr = array(1,2,3,4,5,6,7,8,9,10);
        
        $result = array();
        for ($i = 0; $i < count($arr); $i++) {
            for ($j = 0; $j < 3; $j++) {
                $result[$i][] = $arr[$j];
            }
        }


the result to this code given below

    array (size=10)
    0 => 
      array (size=3)
       0 => int 1
       1 => int 2
       2 => int 3
    1 => 
     array (size=3)
       0 => int 1
       1 => int 2
       2 => int 3
    2 => 
     array (size=3)
       0 => int 1
       1 => int 2
       2 => int 3
    3 => 
     array (size=3)
       0 => int 1
       1 => int 2
       2 => int 3
    4 => 
     array (size=3)
       0 => int 1
       1 => int 2
       2 => int 3
    5 => 
     array (size=3)
       0 => int 1
       1 => int 2
       2 => int 3
    6 => 
     array (size=3)
       0 => int 1
       1 => int 2
       2 => int 3
    7 => 
     array (size=3)
       0 => int 1
       1 => int 2
       2 => int 3
    8 => 
     array (size=3)
       0 => int 1
       1 => int 2
       2 => int 3
    9 => 
     array (size=3)
       0 => int 1
       1 => int 2
       2 => int 3
        
