Generating random HTML Code / Ad banner with PHP

Many times,  I feel the need to use a code to display random content on my websites. There are many options available to achieve this.  Web developers use different scripts and applets for generating random HTML code on to their websites.  Though Javascript is very popular for this purpose and sample codes can be downloaded from web resource sites like DynamicDrive or Javascriptkit.  Now all most every web browser support javascript, so it becomes first choice for web developers. With the gaining popularity of hand held/ mobile devices world over, more and more people now use their smartphones to surf web and send email etc, but not every mobile browser support javascript and thus your content will not be available for users to view. To rescue from this situation web-developers started implementing Server Side Scripting to display special category of content like serving ads on their web pages. I  prefer PHP script which is also a Server Side Script. PHP is relatively easier language to implement into existing web pages. Being an Open Source Language, PHP is supported by mostly every webserver/web-hosting providers. Here is a PHP scipt code that help you generate random HTML code on to your web page.

<?php
//PHP Random HTML Script

$random_number = rand(1, 2); // number of banners to shuffle

$random_banner[1] = &#039;<a href="http://shaadiwala.com" target="_new"><img class="wp-image-1232" src="http://shaadiwala.com/images/creatives/shaadiwala_banner_200x200.jpg" alt="" border="0"></a>';
$random_banner[2] = '<a href="http://shaadiwala.com" target="_new"><img src="http://shaadiwala.com/images/creatives/shaadiwala_box_200x200.jpg" alt="" border="0"></a>;';

// print random banner on web page
echo ("$random_banner[$random_number]");
?>

This very useful PHP script for every web-developer to keep in his Script pile.