如何在PHP中获取矩阵格式

for($i=0;$i<3;$i++){    
  for($j=1;$j<21;$j++){
     echo $values[$i][$j]["score$j"];
  }
}

The above code gives the result as

65432123456543212349
  00000000000000000000
  10543212345654321234

Now I want this result to be in matrix(5*4) format. Eg.

 1=> 6 5 4 3 
     2 1 2 3
     4 5 6 5
     4 3 2 1
     2 3 4 9 

 2=> 0 0 0 0
     0 0 0 0
     0 0 0 0
     0 0 0 0
     0 0 0 0

Thanks in advance.....

Use modulus to determine if your second loop reaches the 4th element and add a new line plus spacing if so.

Also add the key and the => part before entering the second foreach.

Something like this:

for($i=0;$i<3;$i++){    
echo "
" . $i . " => ";    
  for($j=1;$j<21;$j++){
     echo $values[$i][$j]["score$j"]. " ";
     if($j % 4 === 0) {
       echo "
    ";           
     }
  }
}

If you would provide the content of $values in PHP form, we could give a better solution.