This article describes how to obtain a random array list in php. It applies random numbers to array traversal. It is very useful. For more information, see
This article describes how to obtain a random array list in php. It applies random numbers to array traversal. It is very useful. For more information, see
This article describes how to use php to obtain Random Arrays in an array. The specific implementation method is as follows:
Needless to say, directly paste the code. The array_rand in php is abnormal, which breaks through the understanding of normal people and is very tedious.
Example 1:
The Code is as follows:
Function create_random_ids ($ min, $ max, $ limited)
{
$ _ Base_ids = range ($ min, $ max );
$ _ Temp_key = array_rand ($ _ base_ids, min (count ($ _ base_ids), $ limited + 10 ));
// Splicing
$ Ids = array ();
For ($ x = 0; $ x <count ($ _ temp_key); $ x ++ ){
$ Ids [] = $ _ base_ids [$ _ temp_key [$ x];
}
Return $ ids;
}
Example 2:
The Code is as follows:
<? Php
$ A = array (, 8 );
The original order of echo "$ a is:
";
Foreach ($ a as $ v)
Echo $ v. "t ";
Shuffle ($ );
Echo"
$ A is in the following order: ";
Foreach ($ a as $ v)
Echo $ v. "t ";
?>
The first result is:
The second result is:
The third result is:
I hope this article will help you with php programming.
,