PHP Case List Sharing

Source: Internet
Author: User

<?php

function Getfourstr ($len)

{

$chars _array = Array (

"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",

"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K",

"L", "M", "N", "O", "P", "Q", "R", "s", "T", "U", "V",

"W", "X", "Y", "Z", "A", "B", "C", "D", "E", "F", "G",

"H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R",

"S", "T", "U", "V", "W", "X", "Y", "Z",

);

$charsLen = count ($chars _array)-1;

$outputstr = "";

for ($i =0; $i < $len; $i + +)

{

$outputstr. = $chars _array[mt_rand (0, $charsLen)];

}

return $outputstr;

}

Echo Getfourstr (4);

?>

part of the function parsing:mt_rand function Description: Mt_rand () returns a random integer.

if no optional parameter min and Max,mt_rand () are provided, the pseudo-random number between 0 and Rand_max is returned.

For example, want a random number between 0 and 46 (including 0 and 46), with Mt_rand (0, 46).

PHP Case List Sharing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.