mercredi 1 juillet 2015

How to use random () function to shuffle array in PHP

In one interview I was asked to shuffle an associative array that has value like .

$card = array (
               "car"=>1,
                "bus"=>2,
                "truck"=>3,
);

etc. Using a radom function that generate random digit between 0,1 ;

They asked me not to use any inbuilt PHP function .

input: associative array;
output: randomly sequenced associative array;

Thanks & Regards




Aucun commentaire:

Enregistrer un commentaire