Re: random string

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux