PHP Coding Tips

Friday, August 10, 2012

How to randomize array in PHP ?

If you want to random order of elements in your php array, use shuffle function:$somethings = array(); $somethings[0] = "element1"; $somethings[1] = "element2"; $somethings[2] = "element3"; shuffle( $somethins );Notice that this will modify that array wich you put as a argument (pass by reference)

No comments:

Post a Comment