summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2006-02-05 20:52:33 +0000
committerScott Ullrich <sullrich@pfsense.org>2006-02-05 20:52:33 +0000
commita9ea8b8f0f871a7e327389bedae0305f5981e2d8 (patch)
treebd8cae2fd0ecfdf7e4be157ad29cc0c9e642247f
parente428c94d112e891b3de4d2eee678f3a1a49e3f36 (diff)
downloadpfsense-a9ea8b8f0f871a7e327389bedae0305f5981e2d8.zip
pfsense-a9ea8b8f0f871a7e327389bedae0305f5981e2d8.tar.gz
Add uniqueArray() which returns a unique array (removes duplicates)
-rw-r--r--etc/inc/pfsense-utils.inc15
1 files changed, 15 insertions, 0 deletions
diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc
index 6205008..eca92df 100644
--- a/etc/inc/pfsense-utils.inc
+++ b/etc/inc/pfsense-utils.inc
@@ -1690,4 +1690,19 @@ function print_value_list($list, $count = 10, $separator = ",") {
return $list;
}
+function uniqueArray($array)
+{
+ // Get unique elts as keys in assoc. array
+ for ($i=0,$n=count($array, 1);$i<$n;$i++)
+ $u_array[$array[$i]] = 1;
+
+ // Copy keys only into another array
+ reset($u_array, 1);
+ for ($i=0,$n=count($u_array, 1);$i<$n;$i++) {
+ $unduplicated_array[] = key($u_array, 1);
+ next($u_array, 1);
+ }
+ return $unduplicated_array;
+}
+
?> \ No newline at end of file
OpenPOWER on IntegriCloud