note 83514 modified in function.rand by felipe

From: Date: Fri, 30 May 2008 11:30:05 +0000
Subject: note 83514 modified in function.rand by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-139998@lists.php.net to get a copy of this message
For some people who would need to generate random string: <?php function random_letters ($numofletters) { if (!isset($numofletters)) $numofletters = 10; // if $numofletters is not specified sets to 10 letters $literki = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'R', 'S', 'T', 'U', 'W'); $ilosc_literek = count($literki); for ($licz = 0; $licz < $numofletters; $licz++) { $rand = rand(0, $ilosc_literek-1); $vercode = $vercode.$literki[$rand]; } } ?> --was-- For some people who would need to generate random string: function random_letters ($numofletters) { if (!isset($numofletters)) $numofletters = 10; // if $numofletters is not specified sets to 10 letters $literki = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'R', 'S', 'T', 'U', 'W'); $ilosc_literek = count($literki); for ($licz = 0; $licz < $numofletters; $licz++) { $rand = rand(0, $ilosc_literek-1); $vercode = $vercode.$literki[$rand]; } } http://php.net/manual/en/function.rand.php

« previous php.notes (#139998) next »