Friday, 3 December 2021

@3 Tạo và in mảng 2 chiều 5x7 + Tổ đỏ phần tử lẻ

 <!doctype html>

<html>

<head>

<meta charset="utf-8">

<title>Untitled Document</title>

<style>

.c1{color:red;}

</style>

</head>


<body>

<?php

$a=array();

for($i=0;$i<5;$i++)

for($j=0;$j<7;$j++)

$a[$i][$j]=rand(1,30);

for($i=0;$i<5;$i++)

{

for($j=0;$j<7;$j++)

if($a[$i][$j]%2==0)

echo $a[$i][$j]. "&nbsp;";

else

echo "<span class='c1'>{$a[$i][$j]}</span> &nbsp;";

echo "<br/>";

}

?>

</body>

</html>

0 comments:

Post a Comment