function getTheLowestDigit($n) {
$min = 9;
while ($n != 0) {
if ($n % 10 < $min) $min = $n % 10;
$n = (int)($n / 10);
}
return $min;
}
$n = 213;
echo getTheLowestDigit($n) . "\n";
$n = 76594;
echo getTheLowestDigit($n) . "\n";
$n = 76529;
echo getTheLowestDigit($n);
/*
run:
1
4
2
*/