Random display by PHP

September 10th, 2010 at 04:35pm Jason 28 views

Sometimes I need to display a Ad or codes Randomly on my website. here is the php code can give out the result, share with you! you can use it for the Ads, Images, Flash…all kinds of codes.

1
2
3
4
5
6
7
8
9
<?php
    $ad = array(
        "Code_1",
        "Code_2",
        "Code_3",
    );    //Random Codes
    $rand = array_rand($ad);    //Get the Random number
    echo $ad[$rand];    //Display the Code View
?>

Entry Filed under: WordPress Tagged with:

Share This Post Share This Post SubscribePrint This Post Print This PostSave As PDF Save As PDF

Related Posts Hot Posts Hot Comments Hot Tags

      Leave a Comment

      Required

      Required, hidden

      Some HTML allowed:
      <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

      Trackback this post  |  Subscribe to the comments via RSS Feed


      Calendar

      September 2010
      MTWTFSS
      « Aug Oct »
       12345
      6789101112
      13141516171819
      20212223242526
      27282930 

      Sponsors

      Most Recent Posts