<!DOCTYPE html>
<html>
<body>
<?php
$start = 1;
$end = 200;
$flag = 0;
for($start=$start; $start<=$end; $start++)
{
$copyNum = $start;
$total = 0;
$digits = 0;
$remainder = 0;
// find the number of digits in start variable
while($copyNum != 0)
{
$digits++;
$copyNum = floor($copyNum / 10);
}
$copyNum = $start;
//slice the start variable from last digit
while($copyNum != 0)
{
$remainder = $copyNum % 10;
$total += pow($remainder, $digits);
$copyNum = floor($copyNum / 10);
}
//result
if(($start == $total) && ($start != 0))
{
if($flag == 0)
{
echo "Armstrong numbers between $start and $end:<br>";
$flag = 1;
}
echo "$start ";
}
}
if($flag == 0)
echo "There is no armstrong numbers between the given range.";
?>
</body>
</html>