<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                ` ~~~ <?php // +---------------------------------------------------------------------- // | Created by PHPstorm: JRKAdmin框架 [ JRKAdmin ] // +---------------------------------------------------------------------- // | Copyright (c) 2019~2022 [LuckyHHY] All rights reserved. // +---------------------------------------------------------------------- // | SiteUrl: http://www.luckyhhy.cn // +---------------------------------------------------------------------- // | Author: LuckyHhy <jackhhy520@qq.com> // +---------------------------------------------------------------------- // | Date: 2020/1/8-16:52 // +---------------------------------------------------------------------- // | Description: 隨機數生成 // +---------------------------------------------------------------------- namespace Jrk; class Random { /** * @param int $len * @return bool|string * @author: LuckyHhy <jackhhy520@qq.com> * @date: 2020/1/8 * @name: alnum * @describe: 生成數字和字母 */ public static function alnum($len = 6) { return self::build('alnum', $len); } /** * @param int $len * @return bool|string * @author: LuckyHhy <jackhhy520@qq.com> * @date: 2020/1/8 * @name: alpha * @describe:僅生成字符 */ public static function alpha($len = 6) { return self::build('alpha', $len); } /** * @param int $len * @return bool|string * @author: LuckyHhy <jackhhy520@qq.com> * @date: 2020/1/8 * @name: numeric * @describe:生成指定長度的隨機數字 */ public static function numeric($len = 4) { return self::build('numeric', $len); } /** * @param int $len * @return bool|string * @author: LuckyHhy <jackhhy520@qq.com> * @date: 2020/1/8 * @name: nozero * @describe:數字和字母組合的隨機字符串 */ public static function nozero($len = 4) { return self::build('nozero', $len); } /** * @param string $type * @param int $len * @return bool|string * @author: LuckyHhy <jackhhy520@qq.com> * @date: 2020/1/8 * @name: build * @describe: */ public static function build($type = 'alnum', $len = 8) { switch ($type) { case 'alpha': case 'alnum': case 'numeric': case 'nozero': switch ($type) { case 'alpha': $pool = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; break; case 'alnum': $pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; break; case 'numeric': $pool = '0123456789'; break; case 'nozero': $pool = '123456789'; break; } return substr(str_shuffle(str_repeat($pool, ceil($len / strlen($pool)))), 0, $len); case 'unique': case 'md5': return md5(uniqid(mt_rand())); case 'encrypt': case 'sha1': return sha1(uniqid(mt_rand(), true)); } } /** * @param $ps array('p1'=>20, 'p2'=>30, 'p3'=>50); * @param int $num 默認為1,即隨機出來的數量 * @param bool $unique 默認為true,即當num>1時,隨機出的數量是否唯一 * @return array|int|string 當num為1時返回鍵名,反之返回一維數組 * @author: LuckyHhy <jackhhy520@qq.com> * @date: 2020/1/8 * @name: lottery * @describe: 根據數組元素的概率獲得鍵名 */ public static function lottery($ps, $num = 1, $unique = true) { if (!$ps) { return $num == 1 ? '' : []; } if ($num >= count($ps) && $unique) { $res = array_keys($ps); return $num == 1 ? $res[0] : $res; } $max_exp = 0; $res = []; foreach ($ps as $key => $value) { $value = substr($value, 0, stripos($value, ".") + 6); $exp = strlen(strchr($value, '.')) - 1; if ($exp > $max_exp) { $max_exp = $exp; } } $pow_exp = pow(10, $max_exp); if ($pow_exp > 1) { reset($ps); foreach ($ps as $key => $value) { $ps[$key] = $value * $pow_exp; } } $pro_sum = array_sum($ps); if ($pro_sum < 1) { return $num == 1 ? '' : []; } for ($i = 0; $i < $num; $i++) { $rand_num = mt_rand(1, $pro_sum); reset($ps); foreach ($ps as $key => $value) { if ($rand_num <= $value) { break; } else { $rand_num -= $value; } } if ($num == 1) { $res = $key; break; } else { $res[$i] = $key; } if ($unique) { $pro_sum -= $value; unset($ps[$key]); } } return $res; } /** * @return string * @author: LuckyHhy <jackhhy520@qq.com> * @date: 2020/1/8 * @name: uuid * @describe:獲取全球唯一標識 */ public static function uuid() { return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x', mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0x0fff) | 0x4000, mt_rand(0, 0x3fff) | 0x8000, mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff) ); } } ~~~ `
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看