Jump to content

[SOLVED] rand function


maxic0

Recommended Posts

I was looking up and learning about functions, and i was given this example to create a random password.

 

<?php


function rand_pass() {

$chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz";

$thepass = '';

for($i=0;$i<10;$i++)

{

  $thepass .= $chars{rand() % 39};

}

return $thepass;

}   


$password= rand_pass();


echo $password;


?>

 

 

I understand it all apart from the

  $thepass .= $chars{rand() % 39};

 

 

What does the "% 39" bit mean?

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/46578-solved-rand-function/
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.