picking words from a txtfile

Discussion in 'Programming' started by izlik, Nov 9, 2008.

  1. #1
    Hello.

    i have a txtfile with about 300 words in it. currently seperated by a comma "word1,word2,word3," and i was wondering if it's possible in HTML or PHP to pick out at random from that txtfile 30 words and display then asweel as have the word link to someting like for example http://mypage.com/[word]

    i hope someone could help me ifthis is possible.
     
    izlik, Nov 9, 2008 IP
  2. happpy

    happpy Well-Known Member

    Messages:
    926
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    120
    #2
    sure. this is easy

    <?
    $a=file_get_contents("thefile.txt");
    $a=explode(",",$a);
    shuffle($a);
    foreach($a as $b){
    echo"<a href=\"http://search.43.gs/$b\">$b</a> ";
    $n=$n+1;if($n==30){break;}
    }
    ?>
    Code (markup):
    enjoy.
     
    happpy, Nov 10, 2008 IP