Please try not to use adblocker for this small site. Thanks

Monday, 19 January 2015

Random web page and image rotator script

                                               
Are you looking for a script that can randomly rotate webpages or images?

Right, if you are looking for a script that can do what I have mentioned above then you've come to the right place. In this post I'm going to show you a small yet powerful php script which can either rotate only links and images or it can rotate all of the mixed together.

What do you need to do?
You need to create two file, first one PHP (php code goes in this file) and the other one just a plain TXT file (here all the urls and image liks goes) make sure that both (php and txt) files are in the same  directory.

 

Where to put URLs and image links?
 As I have told you before that you need to put all the image links and page urls in the "text" file but make that every singe link should be in separate line as you can see in the picture below.
.....................................................................................................................................................................
.....................................................................................................................................................................

The code.

<?php
$urlist=file("links.txt");
$nl=count($urlist);
$np=rand(0,$nl-1);
$url=trim($urlist[$np]);
header("Location: $url");
exit;
?>


Note: if you rename the txt file then you'll have to edit "links.txt" in the php code as well.
That's it enjoye!!!

3 comments:


  1. This technical post helps me to improve my skills set, thanks for this wonder article I expect your upcoming blog, so keep sharing..
    PHP Course in Chennai

    ReplyDelete
  2. I am reading your post from the beginning, it was so interesting to read & I feel thanks to you for posting such a good blog, keep updates regularly.
    Regards,
    Web design course in Chennai|Web design training in chennai

    ReplyDelete
  3. This is genuinely an awesome read for me. I have bookmarked it and I am anticipating perusing new articles. Keep doing awesome!
    Web Development

    ReplyDelete



NOTE: PLEASE DO NOT SPAM. BY SPAMMING I MEAN LEAVING COMMENT WITH A BACK LINK. I SEE MANY SHAMELESS SPAMMERS STILL TRY TO LEAVE COMMENTS WITH BACK LINKS. FOR THEM I JUST WANT TO SAY COULD YOU PLEASE F**K OFF FROM MY SITE. YOUR (SPAMMER) COMMENT WILL BE REMOVED AS SOON AS I NOTICE IT. Thanks