here's something i just made and tested. seems to work fine.
<?php
$n = 100;
$factors = array();
if ($n > 1) {
for($a = 1; $a <= ($n / 2); $a++) {
if ($n % $a == 0) {
$factors[] = $a;
}
}
foreach($factors as $factor) {
echo "$factor<br />\n";
}
} else {
echo "The number is not an integer greater than 1.";
}
?>
output was:
1
2
4
5
10
20
25
50
i start the for loop at 1, and loop until half of n, because there are no factors of n greater than 0.5n (except for itself of course, and if you use decimals you could factor it). use modulus very simply to see if there is no remainder when dividing by a, if there is none, its a factor and push it to the array, otherwise keep looping. you may want to add for checking is make sure the user entered an integer and not a decimal.