zoukankan      html  css  js  c++  java
  • 随机数

    <?php
        // for($i=873;$i<1100;$i++){
        //     echo "<br>";
        //     echo $i."____".mt_rand(1,10);
        // }
        $ke = range(400, 699);
        $va=r();
        $he=array_combine($ke, $va);
        // var_dump(r());
        foreach ($he as $k => $v) {
            echo "<br>";
            echo $k.'____'.$v;
        }
     
        function r(){
            
            $b=array();
            for($i=0;$i<30;$i++){
                $a= range(1, 10);
                shuffle($a);
                $b=array_merge($b,$a);
            }
            return $b;
        }
     
     
     
     
     
    ?>
     
    ——————————————————————————
     
     
    <?php
    function rand_word($length = 4,$type=1)
    {
    // $chars = '23456789ABCDEFGHJKLMNPQRSTUVWXYZ';
    //纯字母
            if($type==1){
                $chars = '2345678910';
            }else if($type==2){
                $chars = 'ABCDEFGHJKLMNPQRSTUVWXYZ';
            }else if($type==3){
                $chars = '123456789abcdefghijklmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ';
            }
    for ($i = 0, $count = strlen($chars); $i < $count; $i++)
    {
    $arr[$i] = $chars[$i];
    }
     
    mt_srand((double) microtime() * 1000000);
    shuffle($arr);
     
    return substr(implode('', $arr), 5, $length);
    }
     
    echo rand_word(2,2);
     
    date("YmdHis").substr(microtime() * 1000000, 1, 2).$pad;
    
    
    ————————————————————
    function make_password($pw_length){
    	$low_ascii_bound=48;
    	$upper_ascii_bound=122;
    	$notuse=array(58,59,60,61,62,63,64,91,92,93,94,95,96);
    	$i=0;
    	$password1='';
    	while($i<$pw_length)
    	{
    		if(PHP_VERSION<'4.2.0')
    		{
    			mt_srand((double)microtime()*1000000);
    		}
    		$randnum=mt_rand($low_ascii_bound,$upper_ascii_bound);
    		
    		if(!in_array($randnum,$notuse))
    		{
    			$password1=$password1.chr($randnum);
    			$i++;
    		}
    	}
    	return $password1;
    }
    
    echo make_password(6);
    ——————————
    static function get_random_name()
    {
    $str = date('Ymd');

    for ($i = 0; $i < 6; $i++)
    {
    $str .= chr(mt_rand(97, 122));
    }

    return $str;
    }
  • 相关阅读:
    jmeter非GUI模式命令
    jmeter性能测试--浪涌测试
    性能测试之场景设计
    性能测试用例实例
    jmeter常见错误及解决方法
    .NET中变量生存期
    SQL数据库从高版本导入低版本
    对称子字符串
    回溯法求解全排列问题(可去除重复排列)
    快速排序及快速选择问题
  • 原文地址:https://www.cnblogs.com/csjoz/p/7243785.html
Copyright © 2011-2022 走看看