I'm running a random image script, it works like it should. Only problem is, every once in a while it will output a blank path to an image. I've done a few different versions of this. Every script I use, every once in a while it will display a blank path. It will output <img src="">, but that's all. Is there any way to fix this? It would be great if some one could point me in the right direction, I'm stuck.
<?php
$link_target = "<A href=load.xp?uid=ads>";
$link_targetc = "</a>";
$RANDOM_IMG_FILE = "ranimg.txt";
srand((double)microtime()*1000000);
if (file_exists($RANDOM_IMG_FILE)) {
$arry = file($RANDOM_IMG_FILE);
for($i = 0; $i < sizeof($arry) ; $i++) {
if (preg_match("/\w+/", $arry[$i]))
$good_arry[$j++] = chop($arry[$i]);
# PHP 4.0 arry_push ($good_arry, $arry[$i]);
}
$randval = rand(0, sizeof($good_arry) -1);
$html_result = "<IMG SRC=\"$good_arry[$randval]\">";
} else {
$html_result = "error: can't open $RANDOM_IMG_FILE file";
}
?>
<?php echo "$link_target\n$html_result\n$link_targetc"; ?>
Exact data in "ranimg.txt", to the byte.
./imgs/wm3.jpg
./imgs/sth2.jpg
./imgs/sth4.jpg
Thanks for any help you can give me.
-- Derrick