note 62542 added to function.rand
| From: | (1statlastdotcom) | Date: | Thu, 02 Mar 2006 23:01:13 +0000 |
| Subject: | note 62542 added to function.rand | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-104734@lists.php.net to get a copy of this message | ||
I think what jeswanth was shooting for was something like:
php -n -r '
//<?php
$chars = 3;
$length= 6;
while(count($nums) < $chars) $nums[rand(0,9)] = null;
while(strlen($code) < $length) $code .= array_rand($nums);
echo "\ncode: $code\n\n";
//?>
'
(No need to create a file. Just paste that in a terminal to test.)
with $chars = 3 you get codes like:
007277
429942
340343
with $chars = 2 you get codes like:
424244
666161
112122
Now I just have to come up with a use for it!
----
Server IP: 64.71.164.2
Probable Submitter: 63.172.193.57
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.rand.php
Edit -- http://master.php.net/note/edit/62542
Del: integrated -- http://master.php.net/note/delete/62542/integrated
Del: useless -- http://master.php.net/note/delete/62542/useless
Del: bad code -- http://master.php.net/note/delete/62542/bad+code
Del: spam -- http://master.php.net/note/delete/62542/spam
Del: non-english -- http://master.php.net/note/delete/62542/non-english
Del: in docs -- http://master.php.net/note/delete/62542/in+docs
Del: other reasons-- http://master.php.net/note/delete/62542
Reject -- http://master.php.net/note/reject/62542
Search -- http://master.php.net/manage/user-notes.php