note 28810 deleted from function.array-merge by joey

From: Date: Tue, 06 May 2003 17:32:42 +0000
Subject: note 28810 deleted from function.array-merge by joey
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-47591@lists.php.net to get a copy of this message
I have an array with numeric keys and numeric values, and I wanted to condense the array such that if a value exists more than once, it's just taken out. For example, array(1, 3, 5, 10, 5) would condense down to array(1, 3, 5, 10). I don't see a function that behaves exactly like this, but I've been using this function to do it: function array_condense_values($input) { if (!is_array($input)) return (false); $diet_array = array(); foreach ($input as $item) { if (!in_array($item, $diet_array)) { $diet_array[] = $item; } } return ($diet_array); }

« previous php.notes (#47591) next »