"Jason Caldwell" <[EMAIL PROTECTED]> wrote:
> how can i separate the digits in a Double number?
>
> for example:
>
> if i have 3.2 i would like to separate the digits into 3 and 2 and assign
> each to its own variable, like so
>
> numb1 = 3
> numb2 = 2

Use explode() to explode on the "." and save into an array.  Key 0 will be
the integer and key 1 will be the decimal component (without the ".").  Or
if you don't like that use floor() to round it down to next lowest integer
and save that as $integer and then subtract it from the original value to
get the decimal component and use substr() to return everything, but the
first character.  Clearly, the first method is cleaner, but I posed the
second option (which I'd never use) just to demonstrate there are plenty of
solutions for most situations.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to