home

Quickies, by Andrea Olivato

text

Randomize an Array in #php using shuffle

Simple way to re-order an array by random in php.

<?php
    /* First of all I create an array */
    $array = Array(1,2,3,4); 

    /* Now I shuffle it */
    shuffle($array);

    /* Here's the disordered result */
    echo implode(', ',$array);
?>

2 years ago

August 17, 2009
php
Comments (View)
blog comments powered by Disqus