1. Go to this page and download the library: Download lamansky/secure-shuffle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
lamansky / secure-shuffle example snippets
use function Lamansky\SecureShuffle\shuffle;
use function Lamansky\SecureShuffle\shuffle_assoc;
use function Lamansky\SecureShuffle\shuffled;
use function Lamansky\SecureShuffle\shuffled_assoc;
// Shuffles an indexed array in-place.
// Note that we are using the imported shuffle() function,
// not the built-in \shuffle() function.
$arr = [1, 2, 3, 4, 5];
shuffle($arr);
print_r($arr); // Array ( [0] => 4 [1] => 5 [2] => 2 [3] => 1 [4] => 3 )
// Shuffles an associative array in-place.
$arr = ['a' => 1, 'b' => 2, 'c' => 3];
shuffle_assoc($arr);
print_r($arr); // Array ( [b] => 2 [a] => 1 [c] => 3 )
// Creates a shuffled copy of an indexed array.
$orig = [1, 2, 3, 4, 5];
$copy = shuffled($orig);
print_r($orig); // Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 )
print_r($copy); // Array ( [0] => 5 [1] => 2 [2] => 4 [3] => 3 [4] => 1 )
// Creates a shuffled copy of an associative array.
$orig = ['a' => 1, 'b' => 2, 'c' => 3];
$copy = shuffled_assoc($orig);
print_r($orig); // Array ( [a] => 1 [b] => 2 [c] => 3 )
print_r($copy); // Array ( [c] => 3 [a] => 1 [b] => 2 )
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.