English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
shuffle() function shuffles the order of array elements
shuffle( $array );
This function randomly sorts the order of elements in the array.
This function assigns new keys to the elements of the array. It will delete all existing keys you may have assigned, not just rearrange the keys.
Serial Number | Parameters and Description |
---|---|
1 | array (required) It specifies an array. |
Returns TRUE on success, FALSE on failure.
<?php $input = array("d" => "lemon", "a" => "orange", "b" => "banana"); shuffle($input); print_r($input); ?>Test to see‹/›
This will produce the following result. The result will be different each time you shuffle the array.
Array ( [0] => banana [1] => orange [2] => lemon )