OK, here's the modified code (tested and working here):
PHP Code:
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<table><tr>
<?php
$path = "../"; // set path to images, include trailing slash
$linkfile = "links.txt"; // set path and filename to links file
$altfile = "alts.txt"; // set path and filename to alts file
$imar = glob("$path{*.jpg, *.gif}", GLOB_BRACE); // grab images as array (include other image patterns if/as desired)
$links = file($linkfile, FILE_IGNORE_NEW_LINES); // grab links as array
$alts = file($altfile, FILE_IGNORE_NEW_LINES); // grab alts as array
shuffle($links); // random order for links
shuffle($alts); // random order for alts
shuffle($imar); // random order for images
$tnum = -1; // counter for texts
$eol = PHP_EOL; // end of line reference
foreach($imar as $image){
if(++$tnum < 10){ // limit to 10
if($tnum){$html[] = !($tnum % 2)? "</tr>$eol<tr>" : $eol;} // 2 to a row
$html[] = '<td><a href="' . $links[$tnum] . '"><img src="' . $image . '" alt="' . $alts[$tnum] . '"></a></td>'; // table cell template
} else {$html[] = $eol; break;} // all done
}
echo implode($html); // write result
?>
</tr></table>
</body>
</html>
And here is my links.txt (needs at least ten lines, use your own, one of these is local to my system, so won't work for you anyway):
Code:
http://www.google.com/
http://decoymag.com/classifieds/classifi.htm
http://www.dynamicdrive.com/
http://localhost/demos/tidbits/mlb/mlbjqhwformatednest.php
http://www.dynamicdrive.com/forums/showthread.php?81310-Need-Help-with-script
http://www.wussu.com/laotzu/laotzu48.html
https://code.tutsplus.com/tutorials/quick-tip-loop-through-folders-with-phps-glob--net-11274
http://php.net/manual/en/function.array-pop.php
http://1lineart.kulaone.com/#/
https://www.mlb.com/
The alts.txt I used (again, must have at least ten lines):
Code:
some text
Decoys
Dynamic Drive
Games
The Question
Tao
Glob Loops
Array_Pop
Line Art
MLB DOT COM
The more unique images, links, and alts you use, the less repetitions you will see. I used 21 images, which was OK, I'd suggest at least 50 of each though.
Any problems or questions, just let me know.
Bookmarks