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!!!

5 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. You're most welcome my friend, and thanks for your nice encouraging comment. Have nice day. :)

    ReplyDelete
  3. 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
    Replies
    1. I felt so happy when I found out that you are following me from the beginning and I really appreciate for the encouraging comment, that really means a lot to me.Thanks

      Delete
  4. 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