You are here

function units_dimension_subtract in Units of Measurement 7.2

Subtract 2 dimension arrays.

Parameters

array $dimension_minuend: Minuend dimension array

$dimension_subtrahend: Subtrahend dimension array

Return value

array Difference dimension array

2 calls to units_dimension_subtract()
units_dimension_equal in ./units.module
Check whether the 2 dimensions are equal.
units_operator_divide_dimension in plugins/operator/divide.inc

File

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

Code

function units_dimension_subtract($dimension_minuend, $dimension_subtrahend) {
  units_dimension_normalize($dimension_minuend, $dimension_subtrahend);
  $diff = array();
  foreach ($dimension_minuend as $k => $v) {
    $diff[$k] = $dimension_minuend[$k] - $dimension_subtrahend[$k];
  }
  return array_filter($diff);
}