php使用循环输出一个5行4列的表格.(提示:可嵌入html代码实现)
4个回答
展开全部
<?php
$hang = 5;
$lie = 4;
echo "<table>";
for($h = 1; $h<=$hang; $h++){
echo "<tr>";
for($l = 1; $l<=$lie; $l++){
echo "<td>$h行$l列</td>";
}
echo "</tr>";
}
echo "</table>";
?>
$hang = 5;
$lie = 4;
echo "<table>";
for($h = 1; $h<=$hang; $h++){
echo "<tr>";
for($l = 1; $l<=$lie; $l++){
echo "<td>$h行$l列</td>";
}
echo "</tr>";
}
echo "</table>";
?>
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<html><meta charset="utf-8">
<?php
echo "<table>";
for ($i=1; $i<=5; $i++){
echo "<tr>";
for ($j=1; $j<=4; $j++){
echo "<td>".$i."行".$j."列</td>";
}
echo "</tr>";
}
echo "</table>";
?>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<style type="text/css">
td{border:1px solid red;}</style><?php$hang = 5;$lie = 4;echo "<table>";for($h = 1; $h<=$hang; $h++){ echo "<tr>"; for($l = 1; $l<=$lie; $l++){ echo "<td>".$h."行".$l."列</td>"; } echo "</tr>";}echo "</table>";?>
td{border:1px solid red;}</style><?php$hang = 5;$lie = 4;echo "<table>";for($h = 1; $h<=$hang; $h++){ echo "<tr>"; for($l = 1; $l<=$lie; $l++){ echo "<td>".$h."行".$l."列</td>"; } echo "</tr>";}echo "</table>";?>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<?php
$hang = 5;
$lie = 4;
echo "<table border='2'>";
for($h = 1; $h<=$hang; $h++){
echo "<tr>";
for($l = 1; $l<=$lie; $l++){
echo "<td>"."$h".'行'."$l".'列'."</td>";
}
echo "</tr>";
}
echo "</table>";
?>
$hang = 5;
$lie = 4;
echo "<table border='2'>";
for($h = 1; $h<=$hang; $h++){
echo "<tr>";
for($l = 1; $l<=$lie; $l++){
echo "<td>"."$h".'行'."$l".'列'."</td>";
}
echo "</tr>";
}
echo "</table>";
?>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询