You are here

function units_dimension_normalize in Units of Measurement 7.2

Pre-process 2 dimension arrays.

Make sure both have all known dimensions initialized. Sorting them by the dimensions so we can treat them as vectors.

Parameters

array $dimension1: Dimension array #1

$dimension2: Dimension array #2

2 calls to units_dimension_normalize()
units_dimension_add in ./units.module
Sum 2 dimension arrays.
units_dimension_subtract in ./units.module
Subtract 2 dimension arrays.

File

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

Code

function units_dimension_normalize(&$dimension1, &$dimension2) {
  $dimension1 += array_fill_keys(array_keys($dimension2), 0);
  $dimension2 += array_fill_keys(array_keys($dimension1), 0);
  ksort($dimension1);
  ksort($dimension2);
}