shuffle in php example

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………..!!!

Leave a Reply