- array_slice: documentation ( source)
<?php
$product = array('a','b','c','d');
echo '<table border="1">';
echo "<tr><th>Product 1</th><th>Product 2</th><th>Similarity</th></tr>\n";
Foreach($product as $key => $a){
Foreach(array_slice($product, $key+1) as $b){
echo '<tr><td>'.$a.'</td><td>'.$b."</td></tr>\n";
}
}
echo '</table>';