note 116475 added to function.array-rand
| From: | TmyAdeson | Date: | Thu, 08 Jan 2015 14:29:55 +0000 |
| Subject: | note 116475 added to function.array-rand | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-201388@lists.php.net to get a copy of this message | ||
<?php
// You can do this, programmatically, using the following code ... Test It Yourself (TIY)
$colors=array(
'gray','red','orange','green',
'#B2CC80','#CC6699','#B89470','#99CCFF',
);//colors array
$c1=sizeof($colors)-1;//get position of the last element within the colors array
// -- OR, if you prefer --
//$c1=count($colors)-1;//get position of the last element within the colors array
//pick a color at random from the colors array - 'Mersenne Twister based'
$color=$colors[mt_rand(0,$c1)];
echo<<<HERE
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="refresh" content="2">
</head>
<body>
<div style="width:400px; background-color:$color; border:1px; text-align:center;"
>
$color
</div>
</body>
</html>
HERE;
?>
----
Server IP: 72.52.91.14
Probable Submitter: 2.97.167.255
----
Manual Page -- http://php.net/manual/en/function.array-rand.php
Edit -- https://master.php.net/note/edit/116475
Del: integrated -- https://master.php.net/note/delete/116475/integrated
Del: useless -- https://master.php.net/note/delete/116475/useless
Del: bad code -- https://master.php.net/note/delete/116475/bad+code
Del: spam -- https://master.php.net/note/delete/116475/spam
Del: non-english -- https://master.php.net/note/delete/116475/non-english
Del: in docs -- https://master.php.net/note/delete/116475/in+docs
Del: other reasons-- https://master.php.net/note/delete/116475
Reject -- https://master.php.net/note/reject/116475
Search -- https://master.php.net/manage/user-notes.php