shuffle in php example

(Last Updated On: August 11, 2016)

It just shuffles the array values not keys.

Syntax:

Shuffle($array);

 Program: shuffle.php

<?php
$name_lucky=array(5,4,6,3);
echo "Before shuffle\t\t\n";
print_r($name_lucky);
shuffle($name_lucky); // shuffles the values of name_lucky array.
echo "After shuffle\t\t\n";
print_r($name_lucky);
?>

 

Output:

shuffle

 

Note: Each time you run the values are shuffled.

 

 

Thanks for reading this post………..!!!

192 total views, 0 views today

Leave a Reply

Your email address will not be published. Required fields are marked *