Jump to content

get a random 10 character string


johnmerlino

Recommended Posts

Hey all,

 

I'm looking to produce a random 10 character string like: abcABC0123 when the below method is called:

 

<?php

 

function randomize(){

$chars = explode(' ',(range("a","z"))) . explode(' ',(range("A","Z"))) . explode(' ',(range("0","9")));

$pass = "";

for($i = 0; $i < $len; $i += 1){

array_push($pass,$chars[rand(count($chars)-1)]);

}

return $pass;

}

 

var_dump(randomize(10));

 

?>

But the randomize method is not returning desired result. Any idea what I'm doing wrong?

 

Thanks for response.

Link to comment
https://forums.phpfreaks.com/topic/229337-get-a-random-10-character-string/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.