2
I am learning PHP and I have a job where I have to do the square root and cube of the numbers from 1 to 10, displaying in a table with PHP.
I’ve managed to put the square root of the numbers 1 to 10 all in a square and the same with the cube, but to mount the table in PHP, it’s not working. I have to wear the bow for
. How can I separate each root and cube from the next 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>