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 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Aug 2005
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Creating an algorithm

    I am trying to create an algorithm that takes words from a set of 10-20 words and puts them into any 3-10 word combination, not permutation. I know nothing of scripting and dont even really know if this is the right forum to post into. Any help is greatly appreciated. Thank you.

  • #2
    Regular Coder
    Join Date
    Aug 2004
    Location
    The US of A
    Posts
    767
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Untested.

    PHP Code:
    function randString($wordArray) {
    if(!
    is_array($wordArray)) { return false; }
    $length rand(3,10);
    $string = array();
    for(
    $i=0$i <= $length$i++)
     {
      
    $string[$i] = $wordArray[array_rand($wordArray)];
     }
    return 
    implode(' '$string);



  •  

    Posting Permissions

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