title: php - Advice on how to get every synonym variation for string of words?
body: <p>So I have a string</p>
  
  <pre><code>$string = "funny cat fighting";
  </code></pre>
  
  <p>and I have a 2d array of synonyms such as: </p>
  
  <pre><code>$arr = array (
    0 =&gt; 
    array (
      0 =&gt; 'cat',
      1 =&gt; 'tabby',
      2 =&gt; 'kitty',
      3 =&gt; 'puss'
    ),
    1 =&gt; 
    array (
      0 =&gt; 'funny',
      1 =&gt; 'haha',
      2 =&gt; 'lol'
    ),
    2 =&gt; 
    array (
      0 =&gt; 'war',
      1 =&gt; 'fighting'
    )
  )
  </code></pre>
  
  <p>How would I go about getting every possible synonym variation of <code>$string "funny cat fighting"</code>, for example I'd want the output to be an array of strings:</p>
  
  <pre><code>funny cat fighting
  haha cat fighting
  lol cat fighting
  funny tabby fighting
  </code></pre>
  
  <p>...all variations</p>