Thread: Random Text
View Single Post
Old 05-07-2008, 11:40 AM   #3 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Quote:
Originally Posted by sketchMedia View Post
not very pretty, took about 1min to knock up xD so theres most likely to be mistakes or easier ways:
PHP Code:
$words 'I took my dog for a walk';
$wordArr explode(' '$words);
$cnt count($wordArr);
$randNumStor = array();
//generate an array of random numbers
//make sure that no duplicates exist
for($i 0$i <= $cnt$i++)
{
    
$randNum rand(0$cnt);

    while(
in_array($randNum$randNumStor))
    {
        
$randNum rand(0$cnt);
    }
    
$randNumStor[] = $randNum;
}
//display the words based the random numbers in random array
for($j 0$j <= $cnt$j++)
{
    echo 
$wordArr[$randNumStor[$j]], ' ';

hope i havnt got the wrong end of the proverbial stick.

Edit: i think i may have gotten the wrong idea of you probelm, i just quickly scan read it and saw random text, im keeping it up if i am mistaken, if i have got the wrong idea there are some things in that scrupt that you could use
Works, thanks! but how did it work exactly? its just loops it seems with just adding new elements inside variables. :P
__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote