PHP Array Random Sort
PHP provides another kind of sorting which is called Random Sorting, in PHP shuffle() is used to sort in this manner. This function shuffles an array.
Small description of shuffle function is as follows:
| General Format | Boolean shuffle(array $array) |
| Parameters | array: the array to be sorted |
| Return Value | True/False |
Example 1:
<?php
$array
=array(11,3,85);shuffle(
$array);while
($val=each($array)){
echo $val['key']; echo '=>'; echo $val['value'].'<br/>';}
?>
Output (The output will keep changing after pressing refresh/F5 button):
First Instance:
0=>85
1=>3
2=>11
Second Instance:
0=>85
1=>11
2=>3
Third Instance:
0=>11
1=>85
2=>3
And so on...
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.