Note Submitter: horroradore at gmail dot com
----
Here's the simplest way I've found to get random something without the need for an external file. Simple, but effective.
<?php
function func(){
//Randomize selection. In this case, 5 (0,1,2,3,4,5).
$x = rand()&4;
$vars = array(
//Insert your data into array.
0 => "var1",
1 => "var2",
2 => "var3",
3 => "var4",
4 => "var5"
);
echo $vars[$x];
}
?>
The only problem with that is that it's not really random, and that you sometimes get the same result several times. I've seen sollutions to this using microtime(), but I can't think of them off the top of my head.
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.