diff --git a/core/database.class.php b/core/database.class.php index 254dbffa..f2e9fcc2 100644 --- a/core/database.class.php +++ b/core/database.class.php @@ -371,7 +371,7 @@ class Database { $tags = array_map(array($this, 'resolve_alias'), $tags); $tags = array_map(array($this, 'sanitise'), $tags); - $tags = array_unique($tags); // remove any duplicate tags + $tags = array_iunique($tags); // remove any duplicate tags // delete old $this->delete_tags_from_image($image_id); diff --git a/core/util.inc.php b/core/util.inc.php index 0170cba4..aceac770 100644 --- a/core/util.inc.php +++ b/core/util.inc.php @@ -343,6 +343,23 @@ function array_contains($array, $target) { return false; } +// case insensetive uniqueness +function array_iunique($array) { + $ok = array(); + foreach($array as $element) { + $found = false; + foreach($ok as $existing) { + if(strtolower($element) == strtolower($existing)) { + $found = true; break; + } + } + if(!$found) { + $ok[] = $element; + } + } + return $ok; +} + // from http://uk.php.net/network function ip_in_range($IP, $CIDR) { list ($net, $mask) = split ("/", $CIDR);