Examples

Example #1 Random Example

<?php
$r
= new \Random\Randomizer();

// Generating a random domain name
printf(
"%s.example.com\n",
$r->getBytesFromString('abcdefghijklmnopqrstuvwxyz0123456789', 16)
);

// Shuffle array:
$fruits = [ 'red' => '๐ŸŽ', 'green' => '๐Ÿฅ', 'yellow' => '๐ŸŒ', 'pink' => '๐Ÿ‘', 'purple' => '๐Ÿ‡' ];
echo
"Salad: ", implode(', ', $r->shuffleArray($fruits)), "\n";

// Shuffeling array keys
$fruits = [ 'red' => '๐ŸŽ', 'green' => '๐Ÿฅ', 'yellow' => '๐ŸŒ', 'pink' => '๐Ÿ‘', 'purple' => '๐Ÿ‡' ];

$keys = $r->pickArrayKeys($fruits, 2);
// Look up the values for the picked keys.
$selection = array_map(
static fn (
$key) => $fruits[$key],
$keys
);

echo
"Values: ", implode(', ', $selection), "\n";
?>

The above example will output something similar to:

j87fzv1p0daiwmlo.example.com
Salad: ๐Ÿฅ, ๐Ÿ‡, ๐ŸŽ, ๐ŸŒ, ๐Ÿ‘
Values: ๐ŸŒ, ๐Ÿ‘