SimplePortal

Customization => Custom Coding => Topic started by: ehsizzup on June 07, 2009, 01:04:25 AM

Title: Use of RAND to show random include page in block
Post by: ehsizzup on June 07, 2009, 01:04:25 AM
Hi.

I have a block that I would like to use to show a random section of html code.

kind of like....

$rand = rand (1,some number)

if $rand = 1 show some html

if $rand = 2 show some different code

etc....


This is probably 10 lines of code.  Can someone hook me up?

Title: Re: Use of RAND to show random include page in block
Post by: Nathaniel on June 07, 2009, 01:26:46 AM
* Split from the sticky topic.

Some PHP code for a Custom PHP block:
Code: [Select]
$html = array(
   'htmlcode',
   'different html code',
   'other html code',
   'more html code',
);

echo $html[rand(0, count($html) - 1)];

You can add as many entries into the array as you like (make sure that you escape any ' quotes like this \').
Title: Re: Use of RAND to show random include page in block
Post by: ehsizzup on June 07, 2009, 08:52:50 PM
Thanks again.

SimplePortal 2.3.8 © 2008-2024, SimplePortal