<?php
$file = "path/to/text/file.txt";
$data = file($file);
$line = trim($data[rand(0,count($data))]);
echo '<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/'.$line.'"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/'.$line.'" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object>';
?>
Dan said:PHP:<?php $file = "path/to/text/file.txt"; $data = file($file); $line = trim($data[rand(0,count($data))]); echo '<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/'.$line.'"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/'.$line.'" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object>'; ?>
nothing shows at all when that happens...Dan said:Does it have the <object... code when nothing appears or does absolutely nothing show up?
<?php
$file = 'path/to/text/file.txt';
$data = file($file);
$line = trim($data[array_rand($data)]);
echo <<<YT
<object width="425" height="350">
<param name="movie" value="http://www.youtube.com/v/$line"></param>
<param name="wmode" value="transparent"></param>
<embed src="http://www.youtube.com/v/$line" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed>
</object>
YT;
?>
SecondVersion said:Try array_rand:
PHP:<?php $file = 'path/to/text/file.txt'; $data = file($file); $line = trim($data[array_rand($data)]); echo <<<YT <object width="425" height="350"> <param name="movie" value="http://www.youtube.com/v/$line"></param> <param name="wmode" value="transparent"></param> <embed src="http://www.youtube.com/v/$line" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed> </object> YT; ?>
Do you know why that worked or why my version randomly didn't work?SecondVersion said:Try array_rand:
Arrays start at key 0, so when you:Dan said:Do you know why that worked or why my version randomly didn't work?
$line = trim($data[rand(0,count($data))]);
$line = trim($data[rand(0,count($data)-1)]);


