请问二维数组矩阵算法
时间:2021-07-01 10:21:17
帮助过:23人阅读
请教二维数组矩阵算法
$ary = array(
'a'=>array('a1','a2'),
'b'=>array('b1','b2'),
'c'=>array('c1','c2'),
);
如何把上面的数组,输出到页面成这样啊
------解决方案--------------------
echo '
';
foreach($ary['a'] as $aV){
foreach($ary['b'] as $bV){
foreach($ary['c'] as $cV){
echo "$aV | $bV | $cV |
";
}
}
}
echo '
';
------解决方案--------------------本帖最后由 xuzuning 于 2014-07-10 18:39:24 编辑
$ary = array(
'a'=>array('a1','a2'),
'b'=>array('b1','b2'),
'c'=>array('c1','c2'),
);
echo "
\n";
echo "a | b | c |
\n";
foreach($ary['a'] as $m) {
foreach($ary['b'] as $n) {
foreach($ary['c'] as $v) {
echo "$m | $n | $v |
\n";
}
}
}
echo "
";[code=html]
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 |
/code]
------解决方案--------------------精华区 迪尔卡积 我问的问题....前后几篇 很完整了