PHP Array shuffle() Function

What is shuffle() Function?

Explanation

The "shuffle()" function can shuffle an array.

Syntax:


shuffle(array)

In the above syntax "array" is the array to be shuffled, the keys of the array will be completely changed.

Example :


<?php
$b=array("1"=>"Grapes","2"=>"Apple","3" =>"Cherry");
shuffle($b);
print_r($b);
?>
Result :

[0] => Apple
[1] => Cherry
[2] => Grapes

In the above example the array "$b" is shuffled and the keys of the array is completely changed.

PHP Topics


Ask Questions

Ask Question