Whilst working on an E-commerce website, written in PHP i came across and issue where i had a price stored in a table as a float.

I wanted to split the pounds, and pence into two variables to make it easier to work with, but then save the results back into 1 field. So this is what i did.

http://uk2.php.net/manual/en/function.explode.php#63110

[sourcecode language=’php’]
//If you want to split a price (float) into pounds and pence.
//or dollors and cents etc etc.

$price = “6.20”;

$split = explode(“.”, $price);
$pound = $split[0]; // piece1
$pence = $split[1]; // piece2

echo “&pound $pound . $pencen”;

[/sourcecode]

Enjoy 🙂