PHP code example of antikirra / array-shuffle

1. Go to this page and download the library: Download antikirra/array-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/ */

    

antikirra / array-shuffle example snippets




ly if the function has not been defined in the global scope
array_shuffle($array, 100500);

// if the function could not be defined globally
\Antikirra\array_shuffle($array, 100500);

// under the hood
\Antikirra\ArrayShuffle\ArrayShuffle::shuffle($array, 100500);



y = [0, 2, 6, 1, 8, 9, 5, 4, 3, 7];

$seed = 100500;

$array1 = array_shuffle($array, $seed);

print_r($array1); // [1, 2, 4, 7, 8, 6, 5, 3, 9, 0]

$array2 = $array1;

for ($i = 0; $i < $seed; $i++) {
    shuffle($array2);
}

$array3 = array_shuffle($array2, $seed);

print_r($array3); // [1, 2, 4, 7, 8, 6, 5, 3, 9, 0]

var_dump($array1 === $array3); // true