PHP Program to Display Multiplication Table

Last Updated:

Using for Loop

In the following example, we will create and display the Multiplication Table for the given number (9) using for loop

Example

PHP Compiler
<?php $table = 9; $length = 10; $i = 1; echo "Multiplication table: $table <br>"; for($i=1; $i<=$length; $i++) echo "$i * $table = ".$i * $table. "<br>"; ?>

Using while Loop

In the following example, we will create and display the Multiplication Table for the given number (9) using while loop

Example

PHP Compiler
<?php $table = 9; $length = 10; $i = 1; echo "Multiplication table: $table <br>"; while($i <= $length) { echo "$i * $table = ".$i * $table. "<br>"; $i++; } ?>

Using do while Loop

In the following example, we will create and display the Multiplication Table for the given number (9) using do while loop

Example

PHP Compiler
<?php $table = 9; $length = 10; $i = 1; echo "Multiplication table: $table <br>"; do{ echo "$i * $table = ".$i * $table ."<br>"; $i++; }while($i <= $length); ?>

Share this Page

Meet the Author