Rounding in php

Simon Leung
Simon Leung used Ask the Experts™
on
Is there any way to separate the decimal value and integer value such that

3.2 will be separate into 3.0 and 0.2 .

Thx
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Analyst Assistant
Commented:
Simon

There are various ways you could do this, here's one.
$number = 3.2;

$int = intval($number);

$decimal = $number - $int;

echo $int."\n".$decimal;

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial