Aqui temos um código simples para exibir imagens (que podem ser banners) linkadas de forma aleatória.
PHP:
-
- /*
- Simple randomizer.
- Roger Johansson, http://www.456bereastreet.com/
- */
- 'href' => 'url-1',
- 'title' => 'title-text-1',
- 'src' => 'image-1.jpg',
- 'alt' => 'alt-text-1'
- ),
- 'href' => 'url-2',
- 'title' => 'title-text-2',
- 'src' => 'image-2.jpg',
- 'alt' => 'alt-text-2'
- ),
- 'href' => 'url-3',
- 'title' => 'title-text-3',
- 'src' => 'image-3.jpg',
- 'alt' => 'alt-text-3'
- ),
- 'href' => 'url-4',
- 'title' => 'title-text-4',
- 'src' => 'image-4.jpg',
- 'alt' => 'alt-text-4'
- ),
- 'href' => 'url-5',
- 'title' => 'title-text-5',
- 'src' => 'image-5.jpg',
- 'alt' => 'alt-text-5'
- )
- );
- $numberOfItems = 3; // Change to the number of items you want
- for ($i = 0; $i <$numberOfItems; $i++) {
- $item = $arrItems[$randItems[$i]];
- echo "\t" . '
- . ($i + 1) . '"> . $item['href'] . '" title="' . $item['title'] . '">
' . "\n";. $item['src'] . '" alt="' . $item['alt'] . '">
- . ($i + 1) . '"> . $item['href'] . '" title="' . $item['title'] . '">
- }
- ?>
"\n";
?>
-------------------------------------------------------------------------------------