note 84518 added to function.mt-rand
| From: | keith at ourwebsite dot ca | Date: | Thu, 17 Jul 2008 10:16:49 +0000 |
| Subject: | note 84518 added to function.mt-rand | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-141611@lists.php.net to get a copy of this message | ||
This is how I generate a random colour for backgrounds, graphs, text colour etc.
<?
$total = "9";
$start = "0";
$randcolour = mt_rand($start, $total);
$randcolour .= mt_rand($start, $total);
$randcolour .= mt_rand($start, $total);
$randcolour .= mt_rand($start, $total);
$randcolour .= mt_rand($start, $total);
$randcolour .= mt_rand($start, $total);
?>
<table width="200px" border="0" cellspacing="10"
cellpadding="0" bgcolor="#<? echo $randcolour; ?>">
<tr>
<td>This table has a random background colour</td>
</tr>
</table>
----
Server IP: 216.235.15.211
Probable Submitter: 24.70.191.160
----
Manual Page -- http://www.php.net/manual/en/function.mt-rand.php
Edit -- https://master.php.net/note/edit/84518
Del: integrated -- https://master.php.net/note/delete/84518/integrated
Del: useless -- https://master.php.net/note/delete/84518/useless
Del: bad code -- https://master.php.net/note/delete/84518/bad+code
Del: spam -- https://master.php.net/note/delete/84518/spam
Del: non-english -- https://master.php.net/note/delete/84518/non-english
Del: in docs -- https://master.php.net/note/delete/84518/in+docs
Del: other reasons-- https://master.php.net/note/delete/84518
Reject -- https://master.php.net/note/reject/84518
Search -- https://master.php.net/manage/user-notes.php