Computer >> Computer tutorials >  >> Programming >> PHP

shuffle() function in PHP


The shuffle() function shuffles an array returns TRUE on success and FALSE on failure.

Syntax

shuffle(arr)

Parameters

  • arr − The specified array

Return

The shuffle() function returns TRUE on success and FALSE on failure.

Example

The following is an example −

<?php
$arr = array("mac", "windows", "linux", "solaris");
shuffle($arr);
print_r($arr);
?>

Output

Array (
   [0] => linux
   [1] => windows
   [2] => mac
   [3] => solaris
)