#native_company# #native_desc#
#native_cta#

Random Quote Generator

By Shankar Ramachandran
on June 1, 2004

Version: 1.0

Type: Sample Code (HOWTO)

Category: Math Functions

License: GNU General Public License

Description: This is a PHP application that generates random quotes stored in array and streamd it back to the browser

<html>
<head>
<title>Random Quote Generation</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF" text="#000000">
<font color="#0033FF">The following is the php code for random quote generation 
using the functionality of arrays : </font> <code>
<p>&lt;?php</p>
<p>srand((float) microtime() * 10000000);<br>
  // Quotes go inside the array<br>
  $quote = array(&quot;Hi! How are you ?&quot;, &quot;Hey! Good to see you !&quot;, 
  &quot;Hey Man ! How are you doin?&quot;,&quot;Have'nt we met before!&quot;);<br>
  // Random quote is generated by array_rand and the variable is assigned to it<br>
  //The number in the parenthesis = number of quotes you have in total<br>
  $echo = array_rand($quote,4);</p>
<p>?&gt;</p>
<p>&lt;center&gt; &lt;h2&gt;<br>
  &lt;?</p>
<p>echo $quote[$echo[1]];<br>
  ?&gt;<br>
  &lt;/h2&gt;<br>
  &lt;center&gt;</p>
  </code>
</body>
</html>