...

View Full Version : Creating an algorithm



cabonie
08-25-2005, 03:10 AM
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.

Kurashu
08-25-2005, 05:10 AM
Untested.



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);
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum