Random number generator

Discussion in 'PHP' started by ftnothing, May 20, 2010.

  1. #1
    How can I make a random number generator pop up everytime someone visits my site?
     
    ftnothing, May 20, 2010 IP
  2. MyVodaFone

    MyVodaFone Well-Known Member

    Messages:
    1,048
    Likes Received:
    42
    Best Answers:
    10
    Trophy Points:
    195
    #2
    Every time, same person, how many digits ?

    Explain more....

    EDIT:

    Without further details, I don't know if this helps ?
    
    <?php
    function genRandomString($length) {
        $characters = "0123456789";  
        for ($p = 0; $p < $length; $p++) {
            $string .= $characters[mt_rand(0, strlen($characters))];
        }
        return $string;
    }
    
    $string = genRandomString(5); // Not more then 5 digits
    
    echo $string;
    
    ?> 
    
    PHP:
    Just <?php echo $string; ?> where you want it to appear
     
    Last edited: May 20, 2010
    MyVodaFone, May 20, 2010 IP