php - Advice on how to get every synonym variation for string of words?
20:24 07 Oct 2017

So I have a string

$string = "funny cat fighting";

and I have a 2d array of synonyms such as:

$arr = array (
  0 => 
  array (
    0 => 'cat',
    1 => 'tabby',
    2 => 'kitty',
    3 => 'puss'
  ),
  1 => 
  array (
    0 => 'funny',
    1 => 'haha',
    2 => 'lol'
  ),
  2 => 
  array (
    0 => 'war',
    1 => 'fighting'
  )
)

How would I go about getting every possible synonym variation of $string "funny cat fighting", for example I'd want the output to be an array of strings:

funny cat fighting
haha cat fighting
lol cat fighting
funny tabby fighting

...all variations

php combinations cartesian-product