note 77594 added to function.array-rand
| From: | herodesh | Date: | Wed, 05 Sep 2007 10:36:52 +0000 |
| Subject: | note 77594 added to function.array-rand | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-130195@lists.php.net to get a copy of this message | ||
this is to generate a random selection from an array with array_rand preety nice, can be used to
generate random passwords or anything:
$my_array = array("a", "b", "c", "d", "e",
"f", "g", "h", "i", "j", "k",
"l", "m", "n", "o", "p", "0",
"1", "2", "3", "4", "5");
for ($i=0; $i<=10; $i++)
{
$random = array_rand($my_array);
//this generates the random number from the array
$parola .= $my_array[$random];
//here we will display the exact charachter from the array
}
echo $parola; // printing result
----
Server IP: 69.147.83.197
Probable Submitter: 89.121.177.4
----
Manual Page -- http://www.php.net/manual/en/function.array-rand.php
Edit -- https://master.php.net/note/edit/77594
Del: integrated -- https://master.php.net/note/delete/77594/integrated
Del: useless -- https://master.php.net/note/delete/77594/useless
Del: bad code -- https://master.php.net/note/delete/77594/bad+code
Del: spam -- https://master.php.net/note/delete/77594/spam
Del: non-english -- https://master.php.net/note/delete/77594/non-english
Del: in docs -- https://master.php.net/note/delete/77594/in+docs
Del: other reasons-- https://master.php.net/note/delete/77594
Reject -- https://master.php.net/note/reject/77594
Search -- https://master.php.net/manage/user-notes.php