Efficient banner rotation with PHP
- by reggie
I rotate a banner on my site by selecting it randomly from an array of banners.
Sample code as demonstration:
<?php
$banners = array(
'<iframe>...</iframe>',
'<a href="#"><img src="#.jpg" alt="" /></a>',
//and so on
);
echo $banners(rand(0, count($banners)));
?>
The array of banners has become quite big. I am concerned with the amount of memory that this array adds to the execution of my page.
But I can't figure out a better way of showing a random banner without loading all the banners into memory...