基于多维数组的唯一字符串

The answer can be found here: How to generate in PHP all combinations of items in multiple arrays

I need the logic on how to create unique strings looking like this:

alusion alusion ails
alusion alusion ainu
alusion apoints ails

I have a multi dimensional array as input. The key in each dimension represents the position of the word in the final string.

$array = (
  [0] = array('alusion', 'apoints'),
  [1] = array('alusion', 'apoints'),
  [2] = array('ails', 'ainu')
);