Toc
0 results found
Seven Chen
随机生成字符串
2007/10/29 PHP专题 php

[php] function random($length) { $hash = ‘’; $chars = ‘ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_abcdefghijklmnopqrstuvwxyz’; $max = strlen($chars) - 1; mt_srand((double)microtime() * 1000000); $chr_len = rand(3,$length); for($i = 0; $i < $chr_len; $i++) { $hash .= $chars[mt_rand(0, $max)]; } return $hash; } [/php]

本文作者:Seven Chen
版权声明:本文首发于Seven Chen的博客,转载请注明出处!