Home > Backend Development > PHP Tutorial > Randomly shuffle arrays and strings PHP function application test

Randomly shuffle arrays and strings PHP function application test

巴扎黑
Release: 2016-11-23 15:47:57
Original
1207 people have browsed it

<?php
/**
 * 随机打乱数组、字符串PHP函数应用测试
 * 
 * @author flyer0126
 * @date 2011-12-29
 * 
 */
//随机打乱数组
$arr = array(&#39;1&#39;, &#39;2&#39;, &#39;3&#39;, &#39;4&#39;, &#39;5&#39;, &#39;6&#39;);
print_r($arr);
//Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 ) 
shuffle($arr);
print_r($arr);
//Array ( [0] => 3 [1] => 4 [2] => 1 [3] => 2 [4] => 6 [5] => 5 ) 
//随机打乱字符串
$str = &#39;abcdef&#39;;
echo $str;
//abcdef
$stred = str_shuffle($str);
echo $stred;
//dbafec
?>
Copy after login

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template