Page 1 of 1
extract integer and decimal part from mysql
Posted: Mon Jan 19, 2004 4:47 am
by jolan_lars
Hi. can anyone help me with a PHP function where the integer and the decimal parts are extracted from a mixed number.
e.g.
$mix=123.456
$int=123
$dec=456
Thanx a lot!!!
Posted: Mon Jan 19, 2004 4:57 am
by JayBird
Try this
Code: Select all
<?
function split_float($mix) {
$split = explode(".", $mix);
return $split;
}
$mix = 123.456;
$split = split_float($mix);
$int = $split[0]; // Integer
$dec = $split[1]; // Decimal
echo $int;
echo "<BR>";
echo $dec;
?>
Mark
Posted: Mon Jan 19, 2004 5:10 am
by jolan_lars
Exxxactly what i need. Thanx 4 d prompt response.
Regards.