shuffle() function in PHP

PHPProgrammingServer Side Programming

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 −

 Live Demo

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

Output

Array (
   [0] => linux
   [1] => windows
   [2] => mac
   [3] => solaris
)
raja
Published on 15-Oct-2018 15:11:48
Advertisements