static function getFormattedList(&$list) {
$relName = array();
- foreach ($list as $k => $v) {
- $key = substr($k, 0, strpos($k, '_'));
+ foreach ($list as $listItemKey => $itemValue) {
+ // Extract the relationship ID.
+ $key = substr($listItemKey, 0, strpos($listItemKey, '_'));
if (isset($list["{$key}_b_a"])) {
+ $relName["$key"] = $list["{$key}_a_b"];
+ // Are the two labels different?
if ($list["{$key}_a_b"] != $list["{$key}_b_a"]) {
$relName["$key"] = $list["{$key}_a_b"] . ' / ' . $list["{$key}_b_a"];
}
unset($list["{$key}_b_a"]);
+ unset($list["{$key}_a_b"]);
}
else {
+ // If no '_b_a' label exists save the '_a_b' one and unset it from the list
$relName["{$key}"] = $list["{$key}_a_b"];
+ unset($list["{$key}_a_b"]);
}
}
return $relName;