这是我的代码......
<?php
$arr1 = array();
$arr2 = array();
$arr3 = array();
$intial_amount = 1000;
$sum = 0;
for($j = 3; $j<=24; $j = $j + 3)
{
if($j == 3)
{
$arr1[$j] = "";
$sum = $sum + 1000*3;
}
else
{
$sum = $sum + 1000*3;
$sum = $sum + ($sum * 0.02);
$arr1[$j] = $sum;
}
}
for($j = 27; $j<=48; $j = $j + 3)
{
$sum = $sum + 1000*3;
$sum = $sum + ($sum * 0.02);
$arr2[$j] = $sum;
}
for($j = 51; $j<=72; $j = $j + 3)
{
$sum = $sum + 1000*3;
$sum = $sum + ($sum * 0.02);
$arr3[$j] = $sum;
}
$arr = array($arr1,$arr2,$arr3);
foreach($arr as $key => $val)
{
foreach($val as $k => $v)
{
echo $k." ".$v."<br>";
}
echo "<br>";
}
?>
我希望结果分为三列..
答案 0 :(得分:0)
我没有很好地关注您的代码,因为它不清楚您正在做什么,但如果您想在三列中显示列表,请使用CSS&#39; s {{ 1}}:
columns
答案 1 :(得分:0)
如果您使用以下代码:
$arr1 = array();
$arr2 = array();
$arr3 = array();
$intial_amount = 1000;
$sum = 0;
for($j = 3; $j<=24; $j = $j + 3)
{
if($j == 3)
{
$arr1[$j] = "";
$sum = $sum + 1000*3;
}
else
{
$sum = $sum + 1000*3;
$sum = $sum + ($sum * 0.02);
$arr1[$j] = $sum;
}
}
for($j = 27; $j<=48; $j = $j + 3)
{
$sum = $sum + 1000*3;
$sum = $sum + ($sum * 0.02);
$arr2[$j] = $sum;
}
for($j = 51; $j<=72; $j = $j + 3)
{
$sum = $sum + 1000*3;
$sum = $sum + ($sum * 0.02);
$arr3[$j] = $sum;
}
$arr = array($arr1,$arr2,$arr3);
foreach($arr as $key => $val)
{
echo '<div style=" width:33%; float:left">';
foreach($val as $k => $v)
{
echo $k." ".$v."<br>";
}
echo '</div>';
}