note 111277 added to function.rand

From: Date: Fri, 01 Feb 2013 17:40:13 +0000
Subject: note 111277 added to function.rand
Groups: php.notes 
Request: Send a blank email to php-notes+get-193483@lists.php.net to get a copy of this message
If you are looking for generate a random expression, like password with alphanumeric or any other character, use this function: function GeraHash($qtd){ //Under the string $Caracteres you write all the characters you want to be used to randomly generate the code. $Caracteres = 'ABCDEFGHIJKLMOPQRSTUVXWYZ0123456789'; $QuantidadeCaracteres = strlen($Caracteres); $QuantidadeCaracteres--; $Hash=NULL; for($x=1;$x<=$qtd;$x++){ $Posicao = rand(0,$QuantidadeCaracteres); $Hash .= substr($Caracteres,$Posicao,1); } return $Hash; } //Here you specify how many characters the returning string must have echo GeraHash(30); ---- Server IP: 69.147.83.199 Probable Submitter: 187.21.134.220 ---- Manual Page -- http://php.net/manual/en/function.rand.php Edit -- https://master.php.net/note/edit/111277 Del: integrated -- https://master.php.net/note/delete/111277/integrated Del: useless -- https://master.php.net/note/delete/111277/useless Del: bad code -- https://master.php.net/note/delete/111277/bad+code Del: spam -- https://master.php.net/note/delete/111277/spam Del: non-english -- https://master.php.net/note/delete/111277/non-english Del: in docs -- https://master.php.net/note/delete/111277/in+docs Del: other reasons-- https://master.php.net/note/delete/111277 Reject -- https://master.php.net/note/reject/111277 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#193483) next »