Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,150,532 members, 7,808,957 topics. Date: Thursday, 25 April 2024 at 08:01 PM

Php Function To Generate A Random Expression - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Php Function To Generate A Random Expression (1100 Views)

Javascript Function To Java / Help Needed On API Used To Generate Wema Bank Virtual Accounts / User Defined Function To Validate Regular Expression In Javascript (2) (3) (4)

(1) (Reply)

Php Function To Generate A Random Expression by chiwex(m): 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)

Programmer Wanted For Immediate Employment / Questions For android Developers / Where Can I Learn Python in Lagos

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 6
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.