0

I would like to the most possible different sentences from multiple block of words, in php. For example i put in the php code:

"today" "yesturday" | "is" "is not" | "monday" "tuesday"

It would become:

today is monday
yesturday is monday
today is not tuesday
yesturday is tuesday
etc...

How can i create this in php?

Thank you.

1 Answers1

2

Try this

$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";
        }
    }
} 
Med
  • 2,035
  • 20
  • 31