vendredi 22 juillet 2016

php - How to create a random bit stream

How can I generate following random array:

array(1, 0 , 0, 1, 1, 1, 1, 0, 1, 0, 0)

with length = n?

Of course, always the for solution is out there. But is there any One-line simple solution on this, like any combination of array_fill and mt_rand(0, 1)?




Aucun commentaire:

Enregistrer un commentaire