note 36865 added to function.rand

From: Date: Fri, 24 Oct 2003 23:42:46 +0000
Subject: note 36865 added to function.rand
Groups: php.notes 
Request: Send a blank email to php-notes+get-59267@lists.php.net to get a copy of this message
Well, previous example of NumGen is no real alternative to the first from bkreleger, since it still may return "0" even if 10 digits are requested, for example. Anyhow the first might be shortened this way: function NumGen( $length ) { for ( $i = 0; $i < $length; $i++ ) $randnum .= rand( 0, 9 ); return $randnum; } Quite small. ---- Manual Page -- http://www.php.net/manual/en/function.rand.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+36865 Delete -- http://master.php.net/manage/user-notes.php?action=delete+36865&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+36865&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#59267) next »