Page 1 of 1

Help with banner rotation script

Posted: Wed Feb 09, 2011 9:00 am
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

Re: HELP WITH BANNERS ROTATOR SCRIPT

Posted: Wed Feb 09, 2011 9:11 am
by MindOverBody
Try using shuffle function.

Re: HELP WITH BANNERS ROTATOR SCRIPT

Posted: Wed Feb 09, 2011 9:14 am
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.