Help with banner rotation script

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
maria_maria
Forum Newbie
Posts: 1
Joined: Wed Feb 09, 2011 8:44 am

Help with banner rotation script

Post by maria_maria »

Hi, I have this banners rotator script:

Code: Select all

<?php 
//randomly shuffle the array keeping the relation between keys and values 
function shuffle_me($shuffle_me){ 
$randomized_keys = array_rand($shuffle_me, count($shuffle_me)); 
foreach($randomized_keys as $current_key) { 
$shuffled_me[$current_key] = $shuffle_me[$current_key]; 
} 
return $shuffled_me; 
} 
$center_banners=shuffle_me($center_banners); 
$center_banners=array_slice($center_banners, 0, 20); 

$left_banners=shuffle_me($left_banners); 
$right_banners=shuffle_me($right_banners); 
?>
OK, the script runs perfectly at a PHP4 server, but it doesn't work at my current PHP5 server.

I think that the reason is the change at the array_rand log:
5.2.10 - The resulting array of keys is no longer shuffled.

What exactly do I need to change at the script to work at PHP5? As the script is part of a topsite, it is interrelated with multiple programming pages so the change should be the minimum necessary to work with PHP5.

I have done multiple test without results. Consider that my PHP skills are so low. Please, help me!

Maria
User avatar
MindOverBody
Forum Commoner
Posts: 96
Joined: Fri Aug 06, 2010 9:01 pm
Location: Osijek, Croatia

Re: HELP WITH BANNERS ROTATOR SCRIPT

Post by MindOverBody »

Try using shuffle function.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: HELP WITH BANNERS ROTATOR SCRIPT

Post by John Cartwright »

PLEASE DON'T POST YOUR SUBJECT IN ALL CAPS.

Annoying isn't it? I've edited your subject for you this time.
Post Reply