tags:

views:

70

answers:

1

how can I rearrange it randomly and NOT use shuffle function and still be able to randomly arrange all the elements

$input = array("Neo", "Morpheus", "Trinity", "Cypher", "Tank");   
$rand_keys = array_rand($input, 5);   
echo $input[$rand_keys[0]] . "\n";   
echo $input[$rand_keys[1]] . "\n";   
echo $input[$rand_keys[2]] . "\n";   
echo $input[$rand_keys[3]] . "\n";   
echo $input[$rand_keys[4]] . "\n";   

so it shows random names everytime the function is ran. thanks

A: 

Please expand on your question. Are you trying to render 5 elements, but in a random order?

You can pass variables into your elements so perhaps you can pass a rand() into it, to change the output.

http://book.cakephp.org/view/314/Views

$this->renderElement('helpbox', array("helptext" => "Oh, this text is very helpful."));

Then you could switch on $helptext in your element.

Alternatively, you could just switch the $this->renderElement() call by wrapping it in some randomising php.

DavidYell