Forum Home
Press F1
 
Thread ID: 65871 2006-02-03 00:17:00 GST Calculation in PHP Morgenmuffel (187) Press F1
Post ID Timestamp Content User
426532 2006-02-03 00:17:00 Hi all

I need to calculate GST using PHP and am a bit stuck

Heres the problem,

lets say i have $900 GST inclusive and want to work out...
the price without GST
and the amount of GST charged

ok to work this out I would normally just do the following

Price without GST = 900/1.125 = $800
Gst Content = 900 - 800 (Price without GST) = 100

As is usual with PHP my phobia of Div and Mod cause me to end up with weird answers, everyone has their pet bugbears and div & mod are mine

any help would be greatly received
Morgenmuffel (187)
426533 2006-02-03 00:43:00 Price without GST = 900/1.125 = $800
Gst Content = 900 - 800 (Price without GST) = 100Err, wouldn't you just put this into variable form and such?

$someMoney = 900; //including gst
$priceWithoutGST = $someMoney / 1.125;
$GSTContent = $someMoney - $priceWithoutGST;

Or have I misunderstood something?
mejobloggs (264)
426534 2006-02-03 01:05:00 Err, wouldn't you just put this into variable form and such?

$someMoney = 900; //including gst
$priceWithoutGST = $someMoney / 1.125;
$GSTContent = $someMoney - $priceWithoutGST;

Or have I misunderstood something?

No you haven't

thats exactly what i should have done

For some strange reason i got it into my head to use div and mod, and didn't even try the obvious

Thanks
Morgenmuffel (187)
426535 2006-02-03 01:49:00 No problem, glad to help.

I don't know if it was because php was the first programming language I used or what, but I like php a lot better than the .NET stuff I am doing now. At least I am using C# which follows the same syntax rules as far as I know.
mejobloggs (264)
1