I'm learning PHP and I have a job where I have to do the square root and the cube of the numbers from 1 to 10, displaying in a table with PHP.
I have already managed the square root of the numbers from 1 to 10 all in a square and the same with the cube, but to mount the table in PHP, it is not working. I have to use the for
loop. How can I separate each root and cube from the following number?
I used this code:
<!doctype html>
<html>
<head>
<title></title>
</head>
<body>
<table border=1>
<tr>
<th>Cube</th>
<th>Square root</th>
</tr>
<tr>
<td>
<?php
//Cube
for($i=1; $i<=10; $i++) {
echo "$i^3 = ". pow($i,3) . "<br />";
}
?>
</td>
<td>
<?php
//Square Root
for($i=1; $i<=10; $i++) {
echo "√$i = ".sqrt($i) . "<br />";
}
?>
</td>
</tr>
</table>
</body>
</html>