Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to suffle an array in PHP

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 144
    Comment on it

    Hello Readers ,

    If we have the certain array in php and we want to suffle the values of an array then we have the function called shuffle().

    This function randomize the vales in an array.

    Example :

    <?php
    $my_array = array("red","green","blue","yellow","purple");
    
    shuffle($my_array);
    print_r($my_array);
    ?>
    

    Output:

    Array ( [0] => yellow [1] => green [2] => blue [3] => purple [4] => red ) 
    

    Everytime when you will refresh the page , the values will change randomly.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: