$ary = array( 'a'=>array('a1','a2'), 'b'=>array('b1','b2'), 'c'=>array('c1','c2'),);
echo '<table width="150px" border="1">';foreach($ary['a'] as $aV){ foreach($ary['b'] as $bV){ foreach($ary['c'] as $cV){ echo "<tr><td>$aV</td><td>$bV</td><td>$cV</td></tr>"; } }}echo '</table>';
echo '<table width="150px" border="1">';foreach($ary['a'] as $aV){ foreach($ary['b'] as $bV){ foreach($ary['c'] as $cV){ echo "<tr><td>$aV</td><td>$bV</td><td>$cV</td></tr>"; } }}echo '</table>';
$ary = array( 'a'=>array('a1','a2'), 'b'=>array('b1','b2'), 'c'=>array('c1','c2'),);echo "<table>\n";echo "<tr><td>a</td><td>b</td><td>c</td></tr>\n";foreach($ary['a'] as $m) { foreach($ary['b'] as $n) { foreach($ary['c'] as $v) { echo "<tr><td>$m</td><td>$n</td><td>$v</td></tr>\n"; } }}echo "</table>";
a | b | c |
a1 | b1 | c1 |
a1 | b1 | c2 |
a1 | b2 | c1 |
a1 | b2 | c2 |
a2 | b1 | c1 |
a2 | b1 | c2 |
a2 | b2 | c1 |
a2 | b2 | c2 |
精华区有 求笛卡尔积 的代码
精华区有 求笛卡尔积 的代码
$ary = array( 'a'=>array('a1','a2'), 'b'=>array('b1','b2'), 'c'=>array('c1','c2'), 'd'=>array('d1','d2'), 'e'=>array('e1','e2'), //..........多行......);
精华区 迪尔卡积 我问的问题....前后几篇 很完整了