0

Here is part of my code. I'm having trouble making this part work where I need to get the contents of random locations. I know how to file_get_contents from a url but I need to get random url contents on each page load of my script. I need to get say..

contents of http://site1.com/content.txt
contents of http://site2.com/content.txt
contents of http://site3.com/content.txt
etc.. one at a time random

Here is the code:

<p><label for="title">Title</label><br />
<input type="text" id="title" value="<?php $title = file_get_contents('http://www.site1.com/content.txt'); echo $title; ?>" tabindex="1" size="120" name="title" />

This code above works fine for one location of get contents, but I need that that location to be random on each page load. How would I do that?

Matt
  • 163
  • 1
  • 3
  • 15

1 Answers1

1

you are going too localized ....... any way ,

    $locations= Array('http://site1.com/content.txt','http://site2.com/content.txt');
    $title = file_get_contents($locations[array_rand($locations)]); 
    echo $title;
internals-in
  • 4,798
  • 2
  • 21
  • 38