Return to Snippet

Revision: 3643
at August 28, 2007 11:08 by jonhenshaw


Initial Code
/*
Inspired by
Simple randomizer.
Roger Johansson, http://www.456bereastreet.com/
*/
echo '<div class="name">' . "\n";
$items = array(
	1 => array(
		'href' => 'link.html',
		'title' => 'text',
		'src' => 'image-1.jpg',
		'alt' => 'text'
	),
	2 => array(
		'href' => 'link.html',
		'title' => 'text',
		'src' => 'image-2.jpg',
		'alt' => 'text'
	),
	3 => array(
		'href' => 'link.html',
		'title' => 'text',
		'src' => 'image-3.jpg',
		'alt' => 'text'
	),
	4 => array(
		'href' => 'link.html',
		'title' => 'text',
		'src' => 'image-4.jpg',
		'alt' => 'text'
	),
	5 => array(
		'href' => 'link.html',
		'title' => 'text',
		'src' => 'image-5.jpg',
		'alt' => 'text'
	)
);

$item = $items[rand(1,5)];
echo "\t" . '<a href="' . $item['href'] . '" title="' . $item['title'] . '"><img src="' . $item['src'] . '" alt="' . $item['alt'] . '"></a>' . "\n";
echo '</div>' . "\n";

Initial URL


Initial Description
This randomly displays 1 of the 5 arrays (amount of arrays to choose from can be reduced or increased)

Initial Title
Show Random Image, File and/or HTML

Initial Tags
image

Initial Language
PHP