/ Published in: PHP

Visit the link for instructions on how to use it.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php /* Simple randomizer. Roger Johansson, http://www.456bereastreet.com/ */ echo '<ul>' . "\n"; '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" . '<li class="r' . ($i + 1) . '"><a href="' . $item['href'] . '" title="' . $item['title'] . '"><img src="' . $item['src'] . '" alt="' . $item['alt'] . '"></a></li>' . "\n"; } echo '</ul>' . "\n"; ?>
URL: http://www.456bereastreet.com/archive/200701/simple_php_randomizer/
Comments
