Canman2005 Posted October 28, 2008 Share Posted October 28, 2008 Hi all Wondering if someone can help. I have a few variables, they are //weight in grams $weight = '600'; $price = '299.99'; //weight in kilograms (kg) $weight = '45.2'; $price = '699.21'; I need to do a calculation to work out the cost per kilogram (kg) for both my grams variables and also the kilogram (kg) variables What would be the best way to find out the cost per kilogram (kg) Any help would be ace thanks Quote Link to comment Share on other sites More sharing options...
n3ightjay Posted October 28, 2008 Share Posted October 28, 2008 <?php //weight in grams (A) $weightA = '600'; $priceA = '299.99'; //weight in kilograms (kg) (B) $weightB = '45.2'; $priceB = '699.21'; // cost for a $costPerKGA = $priceA / ($weightA * 1000); // cost for b $costPerKGB = $priceB / $weightB; Quote Link to comment Share on other sites More sharing options...
Stephen Posted October 28, 2008 Share Posted October 28, 2008 I think it should be ($weightA / 1000), n3ight. Quote Link to comment Share on other sites More sharing options...
n3ightjay Posted October 28, 2008 Share Posted October 28, 2008 my bad how embarassing .. thanks for the correction Quote Link to comment Share on other sites More sharing options...
Canman2005 Posted October 28, 2008 Author Share Posted October 28, 2008 thanks dudes Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.