- print_r: documentation ( source)
- ord: documentation ( source)
<?php
$testsize = 1000*100;
$bucketcount = 17;
$buckets = array();
// Initialize buckets
for ($i = 0; $i < $bucketcount; $i++) {
$buckets[$i] = 0;
}
// Run the test
for ($i = 0; $i < $testsize; $i++) {
$n = ord(openssl_random_pseudo_bytes(1));
$buckets[$n % $bucketcount]++; // Here is our modulo operation
}
echo "Expected in each bucket: " . ($testsize / $bucketcount) . "\n";
print_r($buckets);