so, trying list of every possible combination of set of words. with input text "1, 2" , values being ("1" => "a", "b", "c") , ("2" => "d", "e"), like: a, d b, d c, d a, e b, e c, e with code have right now, get: a, d b, d c, d how can around this? code: foreach ($words $word) { ($i = 0; $i < count($array); $i++) //for every value { $key = array_keys($array[$i])[0]; if ($word === $key) { $syn = explode("|", $array[$i][$key]); //get synonyms foreach ($syn $s) //for each synonym within { $potential[] = implode(" ", str_replace($key, $s, $words)); } } } } the procedure every word in input text, want go through our entire array of values. in there, have other arrays ("original" => "synonyms"). there, loop through every synonym , add l...