Re: random within random array?
| From: | Marek Kilimajer | Date: | Mon, 21 Apr 2003 16:24:43 +0000 |
| Subject: | Re: random within random array? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-144663@lists.php.net to get a copy of this message | ||
Create 3 arrays:
$first=array('a','b','c','d','e','f','g');
$second=array('es','is','');
$third=array('',"'","''","'''"); // single quotes within double
repeat this as many times as neccessery:
$parts[]=array_rand($first). array_rand($second).array_rand($third);
create the whole string with spaces separating parts:
$whole=implode(' ',$parts);
Bryan Koschmann - GKT wrote:
Okay, now I've got myself lost. Awhile back I posted a message needing help with random characters. Michael Egan (thanks Michael!)was kind enough to send me his code, and others always gave snippets of info. I modified it to what I needed, and it worked great. However, now I am trying to figure something out additional to it. Basically, I need to generate 50 groups of characters. Each group will be made up of 3 different random (sets of) characters. the first set will be random characters from this group: a, b, c, d, e, f, g the second random from this group: es, is, null and the third from this group: null, ', '', ''' (yes those are single quotes) together, I want something like this: ces' c'' a''' gis'' bes fis''' and so on.. I'm sure this seems strange, but if you use Lilypond you probably know what it's for. Anyhow, if I can get any additional pointers that would be great. I don't want to seem like I'm asking everything to be written for me, but I just don't seem to have the programming mindset for things like this. Thank you in advance! Bryan