shuffle() function in php
Last Updated by Pooja Chikara
0 2965
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:

Share:
Recommended Topics:
You May Also Like
PHP Examples
News letter
Subscribe To Never Miss an Article From
Comments
Waiting for your comments