美文网首页
PHP生成指定长度的随机汉字

PHP生成指定长度的随机汉字

作者: 腿长袖子短 | 来源:发表于2022-04-25 15:41 被阅读0次
        /**
         * Desc: 生成指定长度的随机汉字
         * @param integer   $length     长度
         * @return string
         */
        public function makeChineseCharacters($length)
        {
            $chinese = '';
            for ($i=0;$i<$length;$i++)
            {
                $chr = chr(mt_rand(0xB0,0xD0)).chr(mt_rand(0xA1, 0xF0));
                $chinese .= iconv('GB2312', 'UTF-8', $chr);
            }
            return $chinese;
        }
    

    相关文章

      网友评论

          本文标题:PHP生成指定长度的随机汉字

          本文链接:https://www.haomeiwen.com/subject/utnfyrtx.html