PHP

PHP Menu

PHP

shuffle() Function - Definition, Syntax, Parameters, Examples

Definition

The shuffle() function shuffles an array (i.e. randomizes the order of the array elements).

Syntax

shuffle(array)

Parameters

Parameter Description
array Required. Specifies the array to use.

Example

<?php
// Example 1 $cities = array("New York", "London", "Tokyo", "Berlin", "Cairo"); shuffle($cities); print_r($cities); echo "<br>";
// Example 2 $ages = array("Mark" => 22, "Jeff" => 32, "Mike" => 28); shuffle($ages); print_r($ages); echo "<br>";

Introduction

PHP Basics

PHP Advance

PHP OOP

PHP Functions and Methods