armstrong number program in php

Today, We want to share with you armstrong number program in php.In this post we will show you armstrong number between 100 to 999 in PHP program, hear for list of armstrong numbers we will give you demo and example for implement.In this post, we will learn about Check Armstrong Number in GO Program with an example.

Armstrong Number Program in PHP With Example

what is armstrong number?

A simple defination of the Armstrong number is a number that is the all the data sum of its own digits each raised to the power of the total number of digits is equal to the number itself. for example bellow

Example 1: index.php

        <title>Armstrong number in PHP -</title>
        <form method="post">  
            Enter a number:  
            <input type="number" name="number">  
            <input type="submit" value="Submit">

  $number = $_POST['number'];
  $a = $number;  
  $sum  = 0;
  while( $a != 0 )
   $rem   = $a % 10; 
   $sum   = $sum + ( $rem * $rem * $rem );
   $a   = $a / 10;  

  if( $number == $sum )  
   echo "Yes $number an Armstrong Number";  
   echo "$number is not an Armstrong Number";  

PHP Code:

Example 2:


echo "Armstrong number";
echo "not an armstrong number";



not an armstrong number

Example 3: armstrongCheck

function armstrongCheck($number){ 
    $sum = 0;   
    $x = $number;   
    while($x != 0)   
        $rem = $x % 10;   
        $sum = $sum + $rem*$rem*$rem;   
        $x = $x / 10;   
    if ($number == $sum) 
        return 1; 
    return 0;     
$number = 407; 
$flag = armstrongCheck($number); 
if ($flag == 1) 
    echo "Yes it is an Armstrong number"; 
    echo "No"


Yes it is an Armstrong number

I hope you get an idea about Armstrong number in PHP.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.