function getRandomImages numOfEntries rootPath substr _SERVER PHP_SELF

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
function getRandomImages($numOfEntries) {
$rootPath = substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['PHP_SELF'], "/")+1);
$randIndexes = array_rand($this->images, $numOfEntries);
$html = '';
for($i=0; $i<count($randIndexes); $i++) {
$imgPath = $this->images[$randIndexes[$i]];
$html .= '<img src="'.$rootPath.'thumbnails/'.basename($imgPath).'"/>'."\n";
}
return $html;
}