range,shuffle,str_shuffle
print_r(range(1,20));
输出,range产生
Array
(
[0] => 1
[1] => 2
[2] => 3
[3] => 4
[4] => 5
[5] => 6
[6] => 7
[7] => 8
[8] => 9
[9] => 10
[10] => 11
[11] => 12
[12] => 13
[13] => 14
[14] => 15
[15] => 16
[16] => 17
[17] => 18
[18] => 19
[19] => 20
)
$arr = range(1,20); shuffle($arr); print_r($arr);
shuffle将数组本身顺序打乱,将数组本身返回
以上输出:
Array
(
[0] => 19
[1] => 13
[2] => 20
[3] => 3
[4] => 14
[5] => 6
[6] => 7
[7] => 1
[8] => 2
[9] => 17
[10] => 18
[11] => 8
[12] => 4
[13] => 12
[14] => 15
[15] => 11
[16] => 9
[17] => 10
[18] => 16
[19] => 5
)
$arr = range(1,20); $str = implode('',$arr); echo str_shuffle($str)."\n"; echo $str;
输出:
1016633281915412115171119042718
1234567891011121314151617181920
str_shuffle将字符串顺序打乱后,返回打乱后的字符串