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…
Move the banners to html files and change the array to contain only filenames.
Then you can include that file by the name, only loading the banner required.