Array math

Hi

I have a very simple array of 3 values, width, height and length.

$girth_array=array("$length", "$width", "$height");

I need to get the 2 smallest sides and add them together…then multiply by 2 and add the longest side.

I can sort the array from smallest to largest.

sort($girth_array);
foreach ($girth_array as $key => $val) {
echo "AHA[" . $key . "] = " . $val . "\
";
}

which outputs for example

AHA[0] = 80 AHA[1] = 90 AHA[2] = 100 

So I know I need add keys [0] and [1] together…then multiply by 2. And then add [2].

But how to do that?

Many thanks

sort($girth_array);
$value = ($girth_array[0] + $girth_array[1]) * 2 + $girth_array[2];

Thanks aamonkey. Perfect