₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,330,976 members, 8,448,061 topics. Date: Sunday, 19 July 2026 at 04:38 PM

Toggle theme

Php Function To Generate A Random Expression - Programming - Nairaland

Nairaland ForumScience/TechnologyProgrammingPhp Function To Generate A Random Expression (1249 Views)

1 Reply

Php Function To Generate A Random Expression by chiwex(op): 10:11pm On Feb 02, 2018
If you are looking for a code function to generate a random expression, like password with alphanumeric or any other generate a random expression, use this function:

<?php
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);
?>


source: http://php.net
1 Reply

Easy Way To Create A Random Password Generator In PythonJavascript Function To JavaUser Defined Function To Validate Regular Expression In Javascript234

Do Companies Use Amazon Ec2, Digitalocean Etc As Their Hosting ProviderI Need A Programmer To Do Some Editing In My SiteProblems Using Php Curl