Post: PHP Easy Banner Rotator (No database)
11-13-2011, 06:03 PM #1
Default Avatar
Oneup
Guest
(adsbygoogle = window.adsbygoogle || []).push({});
    <?php

$bannerArray = array("banner0.jpg","banner1.jpg","banner2.png","banner3.png");

$numberOfBanners = Count($bannerArray);

$numberOfBanners = $numberOfBanners - 1;

$randomBanner = rand(0,$numberOfBanners);

echo "<img src='images/banners/" . $bannerArray[$randomBanner] ."'/>";

?>


I'll explain what might not make sense to someone who might not know arrays.

Basically when you put something into an array it always starts off at 0.

So when I do Count($bannerArray); So in order to correctly pull one from the array I have to subtract one because Count does what it says and counts how many are in the array. In this case there are 4 but since the array starts at zero, the max number that is in there is 3.
(adsbygoogle = window.adsbygoogle || []).push({});
11-14-2011, 05:55 AM #2
Originally posted by UP View Post
    <?php

$bannerArray = array("banner0.jpg","banner1.jpg","banner2.png","banner3.png");

$numberOfBanners = Count($bannerArray);

$numberOfBanners = $numberOfBanners - 1;

$randomBanner = rand(0,$numberOfBanners);

echo "<img src='images/banners/" . $bannerArray[$randomBanner] ."'/>";

?>


I'll explain what might not make sense to someone who might not know arrays.

Basically when you put something into an array it always starts off at 0.

So when I do Count($bannerArray); So in order to correctly pull one from the array I have to subtract one because Count does what it says and counts how many are in the array. In this case there are 4 but since the array starts at zero, the max number that is in there is 3.


nice m8 good explanation of arrays.
11-14-2011, 07:26 PM #3
Minoko
Banned
    <?php 

$bannerArray = array("banner0.jpg","banner1.jpg","banner2.png","banner3.png");
echo "<img src='images/banners/" . $bannerArray[rand(0,Count($bannerArray))-1] ."'/>";

?>


Much more efficient. no need to waste memory allocations for things that don't need to be stored.

The following 2 users say thank you to Minoko for this useful post:

Correy,
11-15-2011, 06:29 AM #4
You could also do a file search from inside a specific folder and populate the file list into an array from that so you can just modify the folder contents if you want to easily be able to change the list of banners to use.
11-21-2011, 06:33 AM #5
array = parameter if people didn't know :p

you can make wordlists for aircrack like this Winky Winky
11-21-2011, 07:09 PM #6
Epic?
Awe-Inspiring
Originally posted by Team
array = parameter if people didn't know :p

you can make wordlists for aircrack like this Winky Winky


What do you mean by array = parameter?
11-22-2011, 11:42 PM #7
Originally posted by Epic
What do you mean by array = parameter?


its like a parameter.

ex:

    
//Define Variables
player = host;
player = client1;
player = clien2;


then

    
player thread doGod();


so it will give a player a thread of godmode, and when it's done it will go to the next variable. It's very easy Smile or aka an array.

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo