PHP 8.5.0 Alpha 4 available for testing

Beispiele

Beispiel #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";
?>

Das oben gezeigte Beispiel erzeugt eine Γ€hnliche Ausgabe wie:

j87fzv1p0daiwmlo.example.com
Salad: πŸ₯, πŸ‡, 🍎, 🍌, πŸ‘
Values: 🍌, πŸ‘
οΌ‹add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top