You are here

function units_dimension_add in Units of Measurement 7.2

Sum 2 dimension arrays.

Parameters

array $dimension1: Dimension array #1

$dimension2: Dimension array #2

Return value

array Dimension array: result of the sum of the 2 provided dimension arrays

1 call to units_dimension_add()
units_operator_multiply_dimension in plugins/operator/multiply.inc

File

./units.module, line 486
Provide API for managing and converting units of measurement.

Code

function units_dimension_add($dimension1, $dimension2) {
  units_dimension_normalize($dimension1, $dimension2);
  $sum = array();
  foreach ($dimension1 as $k => $v) {
    $sum[$k] = $dimension1[$k] + $dimension2[$k];
  }
  return $sum;
}