FIXED!
Feel free to use my code, no need to cite my work. There was no problem, just that the image size was too small and some weren't showing up. duh.
I will change the size from 100px to 500px for anyone who wants to use this code.
Have fun
我想用互聯網上的一些開放代碼來製作一個隨機Flash生成器。隨機Flash物件頁面PHP
的一部開拓創新代碼:
<?php
$imglist='';
//$img_folder is the variable that holds the path to the swf files.
// see that you dont forget about the "/" at the end
$img_folder = "images/";
mt_srand((double)microtime()*1000);
//use the directory class
$imgs = dir($img_folder);
//read all files from the directory, ad them to a list
while ($file = $imgs->read()) {
if (eregi("swf", $file))
$imglist .= "$file ";
} closedir($imgs->handle);
//put all images into an array
$imglist = explode(" ", $imglist);
$no = sizeof($imglist)-2;
//generate a random number between 0 and the number of images
$random = mt_rand(0, $no);
$image = $imglist[$random];
//display random swf
echo '<embed src="'.$img_folder.$image.'" quality="high"
pluginspage="http://www.macromedia.com/go/getflashplayer"
type="application/x-shockwave-flash" width="100"
height="100"></embed>';
?>
我修改後的代碼:
<?php
$imglist='';
//$img_folder is the variable that holds the path to the swf files.
// see that you dont forget about the "/" at the end
$img_folder = "../files/flash/";
mt_srand((double)microtime()*1000);
//use the directory class
$imgs = dir($img_folder);
//read all files from the directory, ad them to a list
while ($file = $imgs->read()) {
if (preg_match("/(swf)/i", $file))
$imglist .= "$file ";
} closedir($imgs->handle);
//put all images into an array
$imglist = explode(" ", $imglist);
$no = sizeof($imglist)-2;
//generate a random number between 0 and the number of images
$random = mt_rand(0, $no);
$image = $imglist[$random];
//display random swf
echo '<embed src="'.$img_folder.$image.'" quality="high"
pluginspage="http://www.macromedia.com/go/getflashplayer"
type="application/x-shockwave-flash" width="500"
height="500"></embed>';
?>
我是在第一次有上線11 ergi問題,有人告訴我用預浸來取代它,我經歷了並計算出來。
我加載了我的隨機頁面(http://www.nsgaming.us/random/),它閃爍了幾分之一秒,我在文件夾中有一個隨機的閃存對象,但現在它什麼也沒有顯示。
請幫忙嗎?
我的指數顯示如下:
<html>
<head>
<title>test</title>
<?php
include("../menu.php");
include_once('random2.php');
?>
</head>
<body>
<p>This is the random page.</p>
<p>I am planning on having random flash objects load here but still working on it.</p>
</body>
</html>
請記住我是新的網頁設計,HTML和PHP放緩。 如果你可以嘗試,而不是因爲做一些愚蠢的事情而大吼大叫,這可能是發生了什麼事。
我從2頁獲得了'src =「../ files/flash/of」'和'src =「../ files/flash/Mario」',不要認爲這是您的預期 – bansi