<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ryan Inselmann &#187; php</title>
	<atom:link href="http://ryan.inselmann.org/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://ryan.inselmann.org</link>
	<description></description>
	<lastBuildDate>Tue, 28 Jul 2009 03:21:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Random Images</title>
		<link>http://ryan.inselmann.org/2005/02/14/random-images/</link>
		<comments>http://ryan.inselmann.org/2005/02/14/random-images/#comments</comments>
		<pubDate>Mon, 14 Feb 2005 08:25:47 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://ryaninselmann.com/wp/?p=15</guid>
		<description><![CDATA[One way designers add variety to a website is to have a random image appear in the header of the page. A great way to implement this is using the mt_rand() function in php. This function takes two arguments (1 and 5 in the example below) and returns a random integer in the range specified [...]]]></description>
			<content:encoded><![CDATA[<p>One way designers add variety to a website is to have a random image appear in the header of the page.  A great way to implement this is using the mt_rand() function in php. This function takes two arguments (1 and 5 in the example below) and returns a random integer in the range specified by the two arguments.</p>
<p>Example: &lt;?php $logoId = mt_rand(1,5);?&gt;</p>
<p><em>Note: I&#8217;ve been informed that in php &lt; 4.2.0, mt_rand() must be seeded manually.  An easy way to do this is to add this line before your mt_rand() call.</em></p>
<p>&lt;?php mt_srand((double) microtime() * 1000000); ?&gt;</p>
<p>Once you have a variable ($logoId in this example) containing your random integer, you can use that in the file name specified by the source property of your image tag.</p>
<p>Example: &lt;img src=&#8221;/images/logo_v&lt;?php echo $logoId;?&gt;.jpg&#8221; alt=&#8221;alt text&#8221;/&gt;</p>
<p>In this example, if $logoId is 4 then the image source will be /images/logo_v4.jpg. Likewise, if $logoId is 2 then the images source will be /images/logo_v2.jpg.  This is a very easy way to have a random image.  Once you have those two lines of code, you just have to make sure your image files exist and you&#8217;re done.  If you wanted to have six images instead of five, you would just change the 5 in mt_rand() to a 6 and add the appropriate image file to your images folder.</p>
]]></content:encoded>
			<wfw:commentRss>http://ryan.inselmann.org/2005/02/14/random-images/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
