多维数组中的Php计数频率
我需要计算多维数组中所有数字随机数的频率。
<?php
$n = 10;
$numbers = range(0, $n-1);
$rands = array();
echo "<hr>";
echo "<table border>";
for($row=0; $row<=$n;$row++){
echo "<tr>";
for($col=0;$col<=$n;$col++){
$ok = false;
while (!$ok) {
$x = array_rand($numbers);
$ok = !in_array($numbers[$x], $rands) && $numbers[$x] != $col;
echo "<td>" . "$x";
}
}
}
echo"</table>";
echo "<hr>";
echo "<hr>";
echo "<hr>";
$length=count($numbers);
for($i = 0; $i < $length; $i++){
echo $numbers[$i]." => "."<br>";
}
?>
如何在多维数组中创建计数频率?