(PHP Extension) Generating Random Integer in Range
Demonstrates how to generate random integers in a specified range.
<?php
// The version number (9_5_0) should match version of the Chilkat extension used, omitting the micro-version number.
// For example, if using Chilkat v9.5.0.48, then include as shown here:
include("chilkat_9_5_0.php");
// All Chilkat classes can be unlocked at once at the beginning of a program
// by calling UnlockBundle. It requires a Bundle unlock code.
$chilkatGlob = new CkGlobal();
$success = $chilkatGlob->UnlockBundle('Anything for 30-day trial.');
if ($success != true) {
print $chilkatGlob->lastErrorText() . "\n";
exit;
}
$fortuna = new CkPrng();
// Generate random integers between 12 and 24 inclusive
for ($i = 0; $i <= 100; $i++) {
print $fortuna->RandomInt(12,24) . "\n";
}
?>
|