Bonjour,
J'ai ce code qui crée une liste de phrases à partir de differents mots clés:
Voici le résultat:Code:
1
2
3
4
5
6
7
8
9
10
11 $block1 = array("today", "yesturday" ); $block2 = array("is", "is not"); $block3 = array("monday", "tuesday"); foreach($block1 as $word1) { foreach($block2 as $word2) { foreach($block3 as $word3) { echo $word1.' '.$word2.' '.$word3."\n"; } } }
today is monday
today is tuesday
today is not monday
today is not tuesday
yesturday is monday
yesturday is tuesday
yesturday is not monday
yesturday is not tuesday
Je souhaiterai mélanger le listing de ces phrases de facon aleatoire. J'ai essayé ceci mais cela ne marche pas.
Merci pour votre aide.Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 $block1 = array("today", "yesturday" ); $block2 = array("is", "is not"); $block3 = array("monday", "tuesday"); foreach($block1 as $word1) { foreach($block2 as $word2) { foreach($block3 as $word3) { $shuffle = $word1.' '.$word2.' '.$word3."\n"; shuffle($shuffle); foreach ($shuffle as $shuffles) { echo "$shuffles "; } } } }
