diff options
Diffstat (limited to 'app/class')
-rw-r--r-- | app/class/object.class.php | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/app/class/object.class.php b/app/class/object.class.php index 461f1b1..c1ba85c 100644 --- a/app/class/object.class.php +++ b/app/class/object.class.php @@ -71,6 +71,32 @@ class object extends table } /* + * Remove duplicate elements from an array of Scrott objects. This + * function compares object GUIDs to check for uniqueness. Array + * keys are preserved. NULL elements are removed. Resulting array + * is returned. + */ + public static function arrayUnique(array $arr) : array + { + $guids = array(); + $ret = array(); + + foreach ($arr as $k => $v) + { + if ($v === NULL) + continue; + + if (in_array($v->guid, $guids)) + continue; + + $guids[] = $v->guid; + $ret[$k] = $v; + } + + return $ret; + } + + /* * Get the owner of this object. Either a user object or a group * object will be returned. If this object does not have an owner, * NULL will be returned. |