note 104779 added to function.rand

From: Date: Thu, 07 Jul 2011 06:42:45 +0000
Subject: note 104779 added to function.rand
Groups: php.notes 
Request: Send a blank email to php-notes+get-181301@lists.php.net to get a copy of this message
can you explain this? , this script using to get 8 character and number in random. but i don't understand, where i get 53 in: ======================================= srand((double)microtime() * 1000000); $nom_acak = rand() % 53; ======================================= can i change 53 and * 1000000 into other number? please explain it.. in my brain, i was think the formula is 8 % 53. look at my script..: this script using to get eight character and number in random...: =============================================== function pass_acak($panjang=8) { $kar = "ABCDEFGHIJKLMNOPKRSTUVWXYZ0123456789abcdefghijklmnopkrstuvwxyz"; //rand char srand((double)microtime() * 1000000); //do looping for $panjang character(parameter) for ($i=0; $i<$panjang; $i++) //default will be looping 8x { $nom_acak = rand() % 53; //for get one number $pass .= substr($kar, $nom_acak, 1); //get one character } return $pass; //return result ================================================ but maybe i'm wrong about what i'm thinking. please explain it , with simple example.. like this : ========================================== rand([min],[max]) modulus int; //to get residual 6 char from bla bla ============================================ wow, i got headache. please correct my mistakes. ---- Server IP: 202.158.52.162 Probable Submitter: 180.248.93.25 ---- Manual Page -- http://www.php.net/manual/en/function.rand.php Edit -- https://master.php.net/note/edit/104779 Del: integrated -- https://master.php.net/note/delete/104779/integrated Del: useless -- https://master.php.net/note/delete/104779/useless Del: bad code -- https://master.php.net/note/delete/104779/bad+code Del: spam -- https://master.php.net/note/delete/104779/spam Del: non-english -- https://master.php.net/note/delete/104779/non-english Del: in docs -- https://master.php.net/note/delete/104779/in+docs Del: other reasons-- https://master.php.net/note/delete/104779 Reject -- https://master.php.net/note/reject/104779 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#181301) next »