这是我的部分代码。我有麻烦使这部分工作,我需要得到随机位置的内容。我知道如何从一个url file_get_contents,但我需要在我的脚本的每个页面加载随机url内容。我需要得到说…
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
代码如下:
<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" />
上面的代码对于get内容的一个位置工作得很好,但我需要在每个页面加载时该位置是随机的。我该怎么做呢?
你太本地化了.......无论如何,
$locations= Array('http://site1.com/content.txt','http://site2.com/content.txt');
$title = file_get_contents($locations[array_rand($locations)]);
echo $title;