Page 1 of 2 12 LastLast
Results 1 to 15 of 18

Thread: Looking For A Script - Does This Exist?

  1. #1
    You do realize by 'gay' I mean a man who has sex with other men?
    Join Date
    Oct 2003
    Location
    New Orleans, Louisiana.
    Posts
    21,635

    Looking For A Script - Does This Exist?

    Im trying to find a script that will randomize the order of certain word lists.

    For example lets say i have the following words in a text file..

    Cat
    Dog
    Fish

    I would paste them into the script and it would then output something like this..

    Cat
    Dog
    Fish
    CatDog
    CatFish
    DogCar
    DogFish
    FishCat
    FishDog

    Anyone know if such a script exists and if so, do you happen to have a link handy

    Regards,

    Lee


  2. #2
    Corey Bryant
    Guest
    Hm, methinks you stumped me this time. But I will ask this & then take a look - PHP, ASP, or .NET?


  3. #3
    You do realize by 'gay' I mean a man who has sex with other men?
    Join Date
    Oct 2003
    Location
    New Orleans, Louisiana.
    Posts
    21,635
    .php would be preferred if it is to be server based

    Hehe thanks for the help, so far i have checked out hotscripts.com and drawn a blank so im really thinking this is non-existant

    Regards,

    Lee


  4. #4
    Corey Bryant
    Guest
    Ok - I am on it .


  5. #5
    Corey Bryant
    Guest
    Well this is what I sort of have come up with. I do not think any pre-made commercial script is out there.

    I found this for documentation on strings:

    http://us2.php.net/manual/en/ref.strings.php

    And then someone gave me this code - if it works - fantastic:
    Code:
    // Text file containing words 
    $txt = '/path/to/wordfile.txt'; 
    
    $handle = fopen($txt, 'r'); 
    
    if (!$handle) { 
       die('Could not open...'); 
    } 
    
    // set up arrays for storing words and concatenated words 
    $words = array(); 
    $cwords = array(); 
    
    // get the words 
    while (!feof($handle)) { 
       // strip_newlines is not a real function - needs to be implemented 
       array_push($words, strip_newlines(fgets($handle))); 
    } 
    
    // while we still have words 
    for ($i = 0; $i < count($words); $i++) { 
       // get the current word 
       $curword = $words[$i]; 
       // loop over the words 
       foreach ($words as $word) { 
          // if the word is the same as the current word, skip it - i.e. no CatCat 
          if ($word == $curword) { 
             continue; 
          } 
          // append the concatenated word to the array 
          array_push($cwords, $curword.$word); 
        } 
    } 
    
    print_r($words); 
    print_r($cwords);
    (Sorry we usually work on ASP actually).


  6. #6
    You do realize by 'gay' I mean a man who has sex with other men?
    Join Date
    Oct 2003
    Location
    New Orleans, Louisiana.
    Posts
    21,635
    Hehe well i got the setup bit done LOL

    Getting an error and i know nothing about php

    Regards,

    Lee


  7. #7
    Corey Bryant
    Guest
    I'll ask. My pogrammers do ASP so I know enough ASP ot get myself into trouble & enough PHP to be sent to jail


  8. #8
    You do realize by 'gay' I mean a man who has sex with other men?
    Join Date
    Oct 2003
    Location
    New Orleans, Louisiana.
    Posts
    21,635
    Haha thanks Corey, dont go out of your way though.. i appreciate the help and everything but im sure you have more important stuff to do than help me and my need for a new toy to play with LOL

    Regards,

    Lee


  9. #9
    Corey Bryant
    Guest
    No worries. It seems like it should be pretty simple actually. I have emailed a few of my buddies that know more PHP & since I have this part of the script, I would think it should be pretty easy


  10. #10
    Corey Bryant
    Guest
    Try this
    Code:
    // Text file containing words 
    $txt = '/path/to/wordfile.txt'; 
    
    $handle = fopen($txt, 'r'); 
    
    if (!$handle) { 
       die('Could not open...'); 
    } 
    
    // set up arrays for storing words and concatenated words 
    $words = array(); 
    $cwords = array(); 
    
    // get the words
    while (!feof($handle)) {
       // strip_newlines is not a real function - needs to be implemented
       array_push($words, trim(fgets($handle)));
    }
    
    
    // while we still have words 
    for ($i = 0; $i < count($words); $i++) { 
       // get the current word 
       $curword = $words[$i]; 
       // loop over the words 
       foreach ($words as $word) { 
          // if the word is the same as the current word, skip it - i.e. no CatCat 
          if ($word == $curword) { 
             continue; 
          } 
          // append the concatenated word to the array 
          array_push($cwords, $curword.$word); 
        } 
    } 
    
    print_r($words); 
    print_r($cwords);


  11. #11
    You do realize by 'gay' I mean a man who has sex with other men?
    Join Date
    Oct 2003
    Location
    New Orleans, Louisiana.
    Posts
    21,635
    Yep that works thanks

    Now i have one more quick question LOL

    Is there something i can alter to make it only display the word combinations without any of that extra 'funky' stuff? Sorry

    Regards,

    Lee


  12. #12
    Corey Bryant
    Guest
    No worries. I don't test this myself. So more like the output to be:
    Cat
    Dog
    Fish
    CatDog
    CatFish
    DogCar
    DogFish
    FishCat
    FishDog

    Or
    Cat Dog Fish CatDog CatFish DogCat DogFish FishCat FishDog

    (or does it matter)

    Thanks!


  13. #13
    You do realize by 'gay' I mean a man who has sex with other men?
    Join Date
    Oct 2003
    Location
    New Orleans, Louisiana.
    Posts
    21,635
    Originally posted by Corey Bryant
    Cat
    Dog
    Fish
    CatDog
    CatFish
    DogCar
    DogFish
    FishCat
    FishDog
    Like that would be PERFECT!

    Thanks again Corey

    Regards,

    Lee


  14. #14
    Corey Bryant
    Guest
    This is what I was told:

    Instead of:
    Code:
    print_r($words);
    print_r($cwords);
    use:
    Code:
    foreach ($words as $var) echo $var."<br>";
    foreach ($cwords as $var2) echo $var2."<br>";
    So I am guess:
    Code:
    // Text file containing words 
    $txt = '/path/to/wordfile.txt'; 
    
    $handle = fopen($txt, 'r'); 
    
    if (!$handle) { 
       die('Could not open...'); 
    } 
    
    // set up arrays for storing words and concatenated words 
    $words = array(); 
    $cwords = array(); 
    
    // get the words 
    while (!feof($handle)) { 
       // strip_newlines is not a real function - needs to be implemented 
       array_push($words, strip_newlines(fgets($handle))); 
    } 
    
    // while we still have words 
    for ($i = 0; $i < count($words); $i++) { 
       // get the current word 
       $curword = $words[$i]; 
       // loop over the words 
       foreach ($words as $word) { 
          // if the word is the same as the current word, skip it - i.e. no CatCat 
          if ($word == $curword) { 
             continue; 
          } 
          // append the concatenated word to the array 
          array_push($cwords, $curword.$word); 
        } 
    } 
    
    foreach ($words as $var) echo $var."<br>";
    foreach ($cwords as $var2) echo $var2."<br>";


  15. #15
    Corey Bryant
    Guest
    Or even:
    Code:
    $output = array_merge($words,$cwords);
    echo implode("<br>\n",$output);


Posting Permissions

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