mardi 7 juin 2016

How to get a random list value from a php array

How can I get random values from an array with the PHP list function. Normally I have this which just give me the 3 first values in the array:

list($first, $second, $third) = $array;

But I want to get a random value so I did this but I get no error and also no value:

list($first, $second, $third) = array_rand($array);

Please anyone with a clue on how I can achieve this? I want to get only 3 random values from the array




Aucun commentaire:

Enregistrer un commentaire