Write a Armstrong number or not program in php using while loop

Write a armstrong number or not program in php using while loop. This program is finding the number is Armstrong or not in PHP scripting. Program will check the number is armstrong number or not armstrong number in php

<?php 
$number=300;
$result=0;
$x=$number;
while($x!=0)
{
$bal=$x%10;
$result=$result+$bal*$bal*$bal;
$x=$x/10;
}
if($number==$result)
{
echo "it is an armstrong";
}
else
{
echo "it is not armstrong";
}
?>

 

Output:

it is not armstrong

What is armstrong number and why it is called armstrong number

An Armstrong three-digit number is an integer in which the sum of the cubes of its digits equals the number. The angstrom () is a length measurement unit for light wavelengths. It’s the same as 1010 metres, or 0.1 nanometers. Anders Jonas ngström, a 19th-century Swedish physicist, was the inspiration for the name.

What is if else statement and how to implement it for armstrong number

The if-else phrase is run regardless of whether the condition is true or false. The if-else statement differs from the if statement in a few ways. If the provided condition is true, one block of code is executed; if the condition is false, another block of code is executed.