shuffle() function in PHP || PHP Shuffle Function
×


shuffle() function in php

2655

PHP shuffle() function is used to shuffle the keys of array elements means it change the order of array items randomly and assigns new keys. It is an inbuilt function of PHP.

Syntax:

shuffle($array);

here,

$array is a PHP array.

The return type of this function is Boolean means it can return either TRUE or FALSE. It returns 1 on success and 0 on failure.


Example:

<?php
$arr1 = array(1,2,3,4,5,6,7,8,9);
echo "<pre>";
echo "array before using shuffle function <br>";
print_r ($arr1);
shuffle($arr1);
echo "<br> Array after using shuffle function. <br>";
print_r($arr1);
?>

Output:




Best WordPress Hosting


Share:


Discount Coupons

Get a .COM for just $6.98

Secure Domain for a Mini Price



Leave a Reply


Comments
    Waiting for your comments