Page 1 of 1

Generate a random number?

Posted: Thu Jul 26, 2012 11:09 am
by microUgly
I want to make a simple template modification to display random content. The the phpBB template syntax have something like:

Code: Select all

<!-- IF rand(1,2) == 1 -->
  <p>You're number #1</p>
<!-- ELSE -->
  <p>You're number #2</p>
<!-- ENDIF -->
I understand I could do this, but I'm not clear on where the PHP portion is best placed:

Code: Select all

$template->assign_var('COIN_FLIP', rand(1,2));

<!-- IF COIN_FLIP == 1 -->
  <p>You're number #1</p>
<!-- ELSE -->
  <p>You're number #2</p>
<!-- ENDIF -->