Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,154,742 members, 7,824,141 topics. Date: Saturday, 11 May 2024 at 12:19 AM

Php Function To Generate A Random Expression - Programming - Nairaland

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

Easy Way To Create A Random Password Generator In Python / Javascript Function To Java / 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)

Biggest Banking Software Flop This Year / I Need A Woocommerce Developer / 4 Years Of Coding ( Html, Css, & Java) What I Learn!!!

(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. 5
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.