"Chris Wesley" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> On Wed, 11 Dec 2002, Stephen wrote:
>
> > One other question. How would I find the first 0 of a repeating zero.
> > Like 204,000. How would you find the 0 in the 4th column.
>
> For your repeating zeors question, you'll have to make use of some string
> functions or a regexp function.  Look for a pattern of more than 1 zero.


I would check out the modulus operator (%); something
like the following:

$zeros = 0;

// Ensure the number is an integer (if
// you already know this, you can skip
// this step).
// NOTE: no overflow checking!
while ($number != (int) $number) {
    $zeros--;
    $number *= 10;
}

// Look for trailing 0s
while(($number % 10) == 0) {
    $number /= 10;
    $zeros++;
}




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to