/** * This function will merge two dictionaries. If $propertyName and $propertyValue * specified then the merged result will only contains <key Value> pairs, where * value of $propertyName of each Value will be equal or not equal to $propertyValue * based on $condition. * * @param <Dictionary> $dictionary1 * @param <Dictionary> $dictionary2 * @param <string> propertyName * @param <anyType> $propertyValue * @patam <bool> $condition */ public static function Merge($dictionary1, $dictionary2, $propertyName = null, $propertyValue = null, $condition = TRUE) { $mergedDictionary = new Dictionary(); foreach ($dictionary1->_entries as $key => $value) { if ($propertyName != null && !Dictionary::canAdd($value->entry2, $propertyName, $propertyValue, $condition)) { continue; } $mergedDictionary->Add($value->entry1, $value->entry2); } foreach ($dictionary2->_entries as $key => $value) { if ($propertyName != null && !Dictionary::canAdd($value->entry2, $propertyName, $propertyValue, $condition)) { continue; } $mergedDictionary->Add($value->entry1, $value->entry2); } return $mergedDictionary; }