note 105168 deleted from function.array-filter by danbrown

From: Date: Mon, 01 Aug 2011 13:46:36 +0000
Subject: note 105168 deleted from function.array-filter by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-182046@lists.php.net to get a copy of this message
Note Submitter: Friendly Code ---- I required a function that removed a specific duplicate entry from an array and ignoring all others so came up with this: <?php function specified_array_unique($array, $value) { $count = 0; foreach($array as $array_item) { if ( ($count > 0) && ($array_item == $value) ) { unset($array[$array_item]); } if ($array_item == $value) $count++; } return array_filter($array); } ?>

« previous php.notes (#182046) next »