PDA

View Full Version : Generate Random Word?


Deaths
02-27-2005, 04:37 PM
I want to generate a random word, it doesn't need to be completely random (can also be a random word out of a list of 10, or something).

I know for sure this is possible, and I could find this out myself, but I simply don't have the time to do so...

Help would be appreciated, as always :)

Dean C
02-27-2005, 04:42 PM
PHP can't generate random words as it has no dictionary, though you might wanna use vB's searchindex. Run this query:


SELECT title FROM word ORDER BY rand() LIMIT 1

Zero Tolerance
02-27-2005, 05:51 PM
<?php
$words = array();

$words[] = "word 1";
$words[] = "word 2";
$words[] = "word 3";
$words[] = "word 4";
$words[] = "word 5";
$words[] = "word 6";
$words[] = "word 7";
$words[] = "word 8";
$words[] = "word 9";
$words[] = "word 10";

echo $words[rand(0,count($words)-1)];
?>

Just add more random words to the array .. real easy :)

- Zero Tolerance

Deaths
02-28-2005, 05:55 AM
Thanks ZT, just what I needed :)