Weight Conversion Code


Just wondered if anyone can help…??

Had a bespoke system built a while back and as part of it there was some code that when a user entered a weight in Stone or Kg’s it converted it to Lbs.

I now need to change this so it will convert Lbs and Stone to Kg’s. Problem is that the developer is no longer!!

I think this is the code that does it (not 100%) as several pages refer to it when it comes down to weights etc.

Anyone got some ideas?



<?php echo convWeight($_POST['weight'],$_POST['unit']); function convWeight($conv_weight,$conv_unit){ switch ($conv_unit) { case "kg": return sprintf("%1.0f",($conv_weight / 0.454008898574412)); break; case "s": return sprintf("%1.0f",($conv_weight / 0.071494163451271)); break; case "lb": return sprintf("%1.0f",$conv_weight); break; default: return "Error!"; } } ?> lb Kg Stone [/php]
Sponsor our Newsletter | Privacy Policy | Terms of Service