Re: random string
| From: | Richard Lynch | Date: | Tue, 17 Oct 2006 17:03:36 +0000 |
| Subject: | Re: random string | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-243252@lists.php.net to get a copy of this message | ||
On Tue, October 17, 2006 7:30 am, Ross wrote:
> I want to randomise a string
>
> $myrandom = rand("ross", "andrea");
>
> echo $myrandom;
>
> I know this doesn't work but is there a built in function to do this?
I'm not real clear on what "this" is...
Choose a string at random from an array?
$possibles = array('ross', 'andrea');
shuffle($possibles);
echo $possibles[0];
Or are you trying to compose a new string of randomly-selected
characters of a bunch of other strings?
Some combination of these functions might be in the recipe:
http://php.net/mt_rand
http://php.net/shuffle
http://php.net/explode
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?