Forum Moderators: coopster
Every script I've found on the web comes with about 10 different files (one even needed a database?!?!) when all I'm really looking for is:
<?php $file = file_get_contents_randomly ('http://www.example.com/page1.html');
('http://www.example2.com/page.html');
('http://www.example.com/page113.php');
('http://www.example4.com');
Echo $file;
?>
obviously file_get_contents_randomly doesn't exist but I would have thought there would be something similar. The 10 pages of coding seems very dramatic and generally tries to account for all ancient browser types and IP addresses etc. etc.
Anyone know a simple solution please?
Thanks
Mike
<?php
// limit result to 1 set
for($i = 0; $i < 1; $i++)
{
$type[1] = "$a¦$b¦$c¦$d¦$e¦$f¦$g¦$h";
$type[2] ="$a¦$b¦$c¦$d¦$e¦$f¦$g¦$h";
// Done twice because rand calls for 2 values
$randType = rand(1, 2);
// Get one set
$type = explode("¦", $type[$randType]);
// Get the total size of characters
$max = count($type);
// Generate the rand
$randChar = rand(0, $max);
$rand .= $type[$randChar];
// Added in case rand return empty, it could also return
// whatever you want
if (!$rand)
{
$rand=$a;
}
}
// Test it
echo "Rand: ".$rand;
?>
<EDIT>
Obviously $a, b etc.. represent your URI value
</EDIT>
<EDIT 2>
Remember that pipes are broken by the forum
</EDIT 2>
<?
$list = "http://www.yourdomain.com/page1.htm,http://www.yourdomain.com/page2.htm";
function file_get_contents_randomly($list) {
if (strpos($list,",")) {
$urlArray = explode(",",$list);
$randUrl = array_rand($urlArray,sizeof($urlArray));
for ($sk=0; $sk<sizeof($randUrl); $sk++) {
if ($landingPage=file_get_contents($urlArray[$randUrl[$sk]])) {
return $landingPage;
}
}
}
return "No Page Found.";
}
echo file_get_contents_randomly($list);
?>
Hope this helps,
SK
$baseurl = "/";
$pages = array("test.html","index.html","bob.html","link.php");
$index = rand(0, count($pages)); // Pick a number from 0..Max Pages
$content = file_get_contents($baseurl . $pages[$index]);
?>
btw legalheaven, have you received my StickyMail message?