Introduction to array_reverse() function and shuffle() function
array_reverse()
array array_reverse(array)array_reverse() function passes an array as an input parameter and returns an array with the input parameter Arrays with the same values but in reverse order.
Copy code The code is as follows:
$a = array(1,2 ,3,4,5);
$a = array_reverse($a);
for ($i=0; $iecho $a [$i]." ";
?>
The result is:
5 4 3 2 1
shuffle() bool shuffle(array) The shuffle function randomly sorts the incoming array and returns TRUE if successful, otherwise it returns FALSE.
Copy code The code is as follows:
$a = array(1,2 ,3,4,5);
shuffle($a);
for ($i=0; $iecho $a[$i ]." ";
shuffle($a);
echo "
";
for ($i=0; $iecho $a[$i]." ";
?>
Results returned by two calls:
4 1 2 5 3
1 5 2 4 3
http://www.bkjia.com/PHPjc/322125.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/322125.htmlTechArticlearray_reverse() function and shuffle() function introduction array_reverse() array array_reverse(array)array_reverse() function input The parameter is an array and returns an array with the same value as the passed parameter but in the same order...
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn