note 84810 added to function.rand

From: Date: Wed, 30 Jul 2008 23:29:37 +0000
Subject: note 84810 added to function.rand
Groups: php.notes 
Request: Send a blank email to php-notes+get-142965@lists.php.net to get a copy of this message
quick way to generate randomish numbers and simple strings. no messing around with functions, so you can just pop the line into the middle of your existing code. not the most perfect for sure, but ok for plenty of situations... <?php $random_number = intval( "0" . rand(1,9) . rand(0,9) . rand(0,9) . rand(0,9) . rand(0,9) ); // random(ish) 5 digit int $random_string = chr(rand(65,90)) . chr(rand(65,90)) . chr(rand(65,90)) . chr(rand(65,90)) . chr(rand(65,90)); // random(ish) 5 character string ?> hope someone finds it useful for somthing. regards, deeeeeen alxndr0u ---- Server IP: 87.124.64.96 Probable Submitter: 81.100.97.22 ---- Manual Page -- http://www.php.net/manual/en/function.rand.php Edit -- https://master.php.net/note/edit/84810 Del: integrated -- https://master.php.net/note/delete/84810/integrated Del: useless -- https://master.php.net/note/delete/84810/useless Del: bad code -- https://master.php.net/note/delete/84810/bad+code Del: spam -- https://master.php.net/note/delete/84810/spam Del: non-english -- https://master.php.net/note/delete/84810/non-english Del: in docs -- https://master.php.net/note/delete/84810/in+docs Del: other reasons-- https://master.php.net/note/delete/84810 Reject -- https://master.php.net/note/reject/84810 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#142965) next »