Advertisement
alchymyth

ads rotator

Jun 11th, 2011
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.76 KB | None | 0 0
  1. <div class= "ads">
  2.  
  3. <?php
  4. //add all existing and new ad numbers to the list//
  5. $ad_number_list = array( 0, 2, 4,45, 67, 23, 222 );
  6.  
  7. //enter the number of ads to show in the sidebar//
  8. $show_ads = 3;
  9.  
  10. $max_no = count($ad_number_list)-1;
  11.  
  12. $numbers = array(); $old = array();
  13.  
  14. $end = min( $show_ads, $max_no+1 ); //just in case there are less ads than spaces
  15.  
  16. if(function_exists('mba_display_banner')) :
  17.  
  18. //generate some unique array indices//
  19. for( $i=1; $i<=$end; $i++) :
  20. $old = $numbers;
  21. do { $numbers[$i] = (int)rand(0,$max_no); } while ( in_array($numbers[$i], $old) );
  22. endfor;
  23.  
  24. //call the random unique ads
  25. for( $i=1; $i<=$end; $i++) :
  26. $ad_no = $ad_number_list[$numbers[$i]];
  27. mba_display_banner($ad_no);
  28. endfor;
  29.  
  30. endif; ?>
  31.  
  32. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement