note 45656 added to function.array-unique

From: Date: Tue, 14 Sep 2004 13:23:57 +0000
Subject: note 45656 added to function.array-unique
Groups: php.notes 
Request: Send a blank email to php-notes+get-76664@lists.php.net to get a copy of this message
OK, so here's my version that maintains index integrity: function array_unique($array) { $out = array(); // loop through the inbound foreach ($array as $key=>$value) { // if the item isn't in the array if (!in_array($value, $out)) { // add it to the array $out[$key] = $value; } } return $out; } ---- Manual Page -- http://www.php.net/manual/en/function.array-unique.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+45656 Delete -- http://master.php.net/manage/user-notes.php?action=delete+45656&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+45656&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#76664) next »