Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    CSS
    CSS is offline
    New Coder
    Join Date
    Jun 2006
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Random 4-Characters

    What I'm looking for is...
    a script that randomly generates 100 4-letter 'words' that can consist of any amount of letters and numbers (1 letter, 3 numbers; 2 letters, 2 numbers, etc.), with only the exception that each 'word' begins with a letter. I'm newer to scripting, and I need this script rather urgently, and I honestly think I'm not understanding how to get this done. If someone could post this script and I'd be able to look at it, it'd do a lot for me.

  • #2
    Regular Coder devinemke's Avatar
    Join Date
    Dec 2004
    Location
    NYC
    Posts
    443
    Thanks
    0
    Thanked 12 Times in 11 Posts
    PHP Code:
    $numbers range(0,9);
    $letters range('a','z');
    $both array_merge($numbers$letters);

    $string $letters[array_rand($letters)];
    $string .= $both[array_rand($both)];
    $string .= $both[array_rand($both)];
    $string .= $both[array_rand($both)];

    echo 
    $string

  • #3
    CSS
    CSS is offline
    New Coder
    Join Date
    Jun 2006
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks! It works as expected, but is there a way to display 100 per page-load, with breaks in between each? Such as:

    cnsh
    xj35
    d38v
    (... for +97)

  • #4
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,043
    Thanks
    19
    Thanked 42 Times in 42 Posts
    tried this?
    PHP Code:
    for($i 0$i 100$i++){
    $string $letters[array_rand($letters)];
    $string .= $both[array_rand($both)];
    $string .= $both[array_rand($both)];
    $string .= $both[array_rand($both)];

    echo 
    $string;  


  • #5
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Here's an alternative for you:

    PHP Code:
    $secretCode chr(rand(97,122)) . chr(rand(4857)) . chr(rand(4857)) . chr(rand(4857)); 


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •