you have three variables to pass to a function
existing unit
existing unit type
multiplier
so..
define(M_OZ,'ounces');
convert_measure(24, M_OZ,2){
//here you'd have a whole littany of different conversions
//notice I stored 1lb 8oz as 24, you have to store the raw data somewhere as a SINGLE unit (since that's always possible with decimals).
//you'll need a 4th parameter also for overriding expression, so that you can have 1lb be 16 oz if that's the best way to express
//finally you'll need to use the words "pinch" and "dash" when you go the other way. You'll have to technically define what a pinch and dash are :-)
}
function should return an array I believe, one the same unit, since M_OZ was passed, adn one with the preferred conversion:
$measure['equivalent']='48 ounces';
$measure['normal']='3 lb.';
return $measure;
I'm trying to give some pointers, the hard work is up to you and you'll learn something from approaching it. BTW you might search for cooking and baking measure conversion algorithms.
If you want other examples of "algorithms" search the code part of the forum, or seach the forum itself for "address parser" or "phone parser" which I recently did and submitted.
Bon Appetit,
Sam