lundi 17 mai 2021

A list of random float number from 0 to 1 using php?

I want to create a function to print a list of 50 random floats from 0 to 1.

The function to print one random float is simply :

function random_from_0_to_1() 
{
    return (float)rand() / (float)getrandmax();
}

But how do I get a list of 50 numbers in descending order?

I want to use usort() function, but I am not sure how to use it with a list of 50 random floats.




Aucun commentaire:

Enregistrer un commentaire