vendredi 5 août 2016

How randomized array keys with rand() works?

I'm a bit confused about how this works (the title)? For example, i'm setting an array like this

$array[rand(0, 5)] = 'Alex';
$array[rand(0, 5)] = 'Blue';
$array[rand(0, 5)] = 'Dale';
$array[rand(0, 5)] = 'Matt';

An example of a possible result after a var_dump($array); of the array :

Array
(
    [0] => Blue
    [1] => Dale
    [2] => Matt
)

What happens technically?




Aucun commentaire:

Enregistrer un commentaire