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 Link to comment https://forums.phpfreaks.com/topic/130486-solved-cost-per-weight-calc/ 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; Link to comment https://forums.phpfreaks.com/topic/130486-solved-cost-per-weight-calc/#findComment-676902 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. Link to comment https://forums.phpfreaks.com/topic/130486-solved-cost-per-weight-calc/#findComment-676907 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 Link to comment https://forums.phpfreaks.com/topic/130486-solved-cost-per-weight-calc/#findComment-676911 Share on other sites More sharing options...
Canman2005 Posted October 28, 2008 Author Share Posted October 28, 2008 thanks dudes Link to comment https://forums.phpfreaks.com/topic/130486-solved-cost-per-weight-calc/#findComment-676915 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.