note 75830 added to ref.strings
| From: | mike" | Date: | Mon, 18 Jun 2007 00:59:43 +0000 |
| Subject: | note 75830 added to ref.strings | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-127521@lists.php.net to get a copy of this message | ||
Here is a truly random string generator it uses the most common string functions it will work on
anywhere.
<?php
function random_string($max = 20){
$chars = explode(" ", "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 0 1 2 3
4 5 6 7 8 9");
for($i = 0; $i < $max; $i++){
$rnd = array_rand($chars);
$rtn .= base64_encode(md5($chars[$rnd]));
}
return substr(str_shuffle(strtolower($rtn)), 0, $max);
}
?>
----
Server IP: 64.71.164.2
Probable Submitter: 68.230.192.224
----
Manual Page -- http://www.php.net/manual/en/ref.strings.php
Edit -- https://master.php.net/note/edit/75830
Del: integrated -- https://master.php.net/note/delete/75830/integrated
Del: useless -- https://master.php.net/note/delete/75830/useless
Del: bad code -- https://master.php.net/note/delete/75830/bad+code
Del: spam -- https://master.php.net/note/delete/75830/spam
Del: non-english -- https://master.php.net/note/delete/75830/non-english
Del: in docs -- https://master.php.net/note/delete/75830/in+docs
Del: other reasons-- https://master.php.net/note/delete/75830
Reject -- https://master.php.net/note/reject/75830
Search -- https://master.php.net/manage/user-notes.php