Return to Snippet

Revision: 39067
at January 13, 2011 00:02 by bwangila


Initial Code
function split_number ( $number ) 
{
    //Convert any entered number into a float
    $number = number_format ( $number, 1 );

    //Get the integer part
    $intpart = floor ( $number );

    //Get the fraction part
    $fraction = $number - $intpart;
}

Initial URL

                                

Initial Description
I needed to split a decimal number into the integer part and the fraction part and save both of them in different variables

Initial Title
PHP Split a number into the integer and fraction parts

Initial Tags
number

Initial Language
PHP