You are here: Home / Topics / PHP Program to print table of any number?

PHP Program to print table of any number?

Filed under: PHP on 2022-11-16 13:36:32

The below program prints table of a number using a loop. The PHP echo statement is used to output the result on the screen.
Example

<!DOCTYPE html>
<html>
<body>

<?php    
$num = 9;  
for($i=1; $i<=10; $i++)   
{
$product = $i*$num;
echo "$num * $i = $product" ;   
echo '<br>';  
}  
?> 

</body>
</html>


Output

9 * 1 = 9
9 * 2 = 18
9 * 3 = 27
9 * 4 = 36
9 * 5 = 45
9 * 6 = 54
9 * 7 = 63
9 * 8 = 72
9 * 9 = 81
9 * 10 = 90

About Author:
V
Vishal Gupta     View Profile
Hi, I am Vishal Gupta. I like this Website for learning MCQs. This website is good for preparation.