Hello, I am new to PHP programming and recently I've been looking over random generated programs. I ran across this code and I would like to understand it better because the person that wrote it did not write comments or use descriptive names for the variables. Thank you
<?php
function randColor()
{
$r = rand(0,255);
$g = rand(0,255);
$b = rand(0,255);
return sprintf('%02X%02X%02X', $r, $g, $b);
}
$tdata='';
for ($i=0; $i<10; $i++) {
$tdata .= "<tr>";
for ($j=0; $j<20; $j++) {
$colors = randColor();
$tdata .= "<td style='background-color:#$colors'>$colors<br><span class='wtext'>$colors</span></td>";
}
$tdata .= '</tr>';
}
?>
<html>
<head>
<style type='text/css'>
table {
border-collapse: collapse;
}
td {
width: 60px;
height: 60px;
font-family: sans-serif;
font-size: 8pt;
text-align: center;
}
.wtext {
color: white;
}
</style>
</head>
<body>
<table border='1'>
<?=$tdata?>
</table>
</body>
</html>