A simple PHP-script for random text

by 3 replies
8
This PHP-script shows random text/links or what ever you want.
I was thinking about using it to show AdBrite SmartZone ads.
In one SmartZone is max. 25 ads.
Using this script I can show even more.

And yes, I could use AdRotate if I'm using WP.
But, here it is if you need it.


Code:
< ?
//set the urls
$urls = array(
'- Insert text/link/code here -', // Insert your code/text between the ' '
'- Insert text/link/code here -',
'- Insert text/link/code here -',
'- Insert text/link/code here -'); // Last line, use no comment at the end (,)
 
srand(time());
 
//set the number in (rand()%3); for however many links there are
$random = (rand()%4);
echo ("$urls[$random]");
?>
#programming #phpscript #random #simple #text
  • Thank can be usefull
  • Thanks for this post and sharing this script. I hope it will help me in future.
  • The small replacement will make your script easier in use (don't need to assign the number of links manually).

    Remove:
    //set the number in (rand()%3); for however many links there are
    $random = (rand()%4);
    echo ("$urls[$random]");

    Add:

    echo $urls [rand() % count($urls)];

Next Topics on Trending Feed