I have one dimensional array like this
$arr=array('1','2','3','4','5','6','7','8','9','10','11','12','13'......'21');
From this, I want to create a two-dimensional array similar to this.

The dimension of the 2D array depends on the number of elements in the 1D array.
Terms
1. The number of rows in a 2D array is fixed as 5.
2. The number of columns may vary.
3. The third line will be empty except for the last item
Note
The size of the one-dimensional array changes.
We also need to get the dimension of the 2D array, how can I print it?
UPDATE
Here is my code
$k=0;
$l=0;
$i=0;
$A=array('1','2','3','4','5','6','7','8','9','10');
$size=count($arr);
$B=[];
$x=?;
$y=5;
for($i=0;$i<$size;$i++){
$B[k][l]=$A[i];
$k++;
if($k==2 && $l!=$x){
$k++;
}
if($k==4){
$l++;
}
}
How can I get the value $xis the size of the columns of a 2D array