<?php
//case 5 打印金字塔
//当前行
$line = 1;
//空格数
$empty = 1;
//星数
$star = 1;
//塔总行数
$total_line = 30;
echo "<table>";
//总循环
while($line <= $total_line)
{
//空格数计算
$empty = $total_line - $line;
//星数计算
$star = 2 * $line - 1;
//空格当前位置
$empty_pos = 1;
//星当前位置
$star_pos = 1;
echo "<tr>";
//输出空格
while($empty_pos <= $empty)
{
echo "<td> </td>";
$empty_pos++;
}
//输出星
while($star_pos <= $star)
{
echo "<td>*</td>";
$star_pos++;
}
//输出对称面空格
while($empty_pos >= 1)
{
echo "<td> </td>";
$empty_pos--;
}
echo "</tr>";
//当前行后移
$line++;
}
echo "</table>";