1$price = 1234.44;
2
3$whole = intval($price); // 1234
4$decimal1 = $price - $whole; // 0.44000000000005 uh oh! that's why it needs... (see next line)
5$decimal2 = round($decimal1, 2); // 0.44 this will round off the excess numbers
6$decimal = substr($decimal2, 2); // 44 this removed the first 2 characters
7
8if ($decimal == 1) { $decimal = 10; } // Michel's warning is correct...
9if ($decimal == 2) { $decimal = 20; } // if the price is 1234.10... the decimal will be 1...
10if ($decimal == 3) { $decimal = 30; } // so make sure to add these rules too
11if ($decimal == 4) { $decimal = 40; }
12if ($decimal == 5) { $decimal = 50; }
13if ($decimal == 6) { $decimal = 60; }
14if ($decimal == 7) { $decimal = 70; }
15if ($decimal == 8) { $decimal = 80; }
16if ($decimal == 9) { $decimal = 90; }
17
18echo 'The dollar amount is ' . $whole . ' and the decimal amount is ' . $decimal;