note 5864 deleted from function.array-flip by irc-html
| From: | irc-html@php.net | Date: | Sat, 19 Jan 2002 21:00:48 +0000 |
| Subject: | note 5864 deleted from function.array-flip by irc-html | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-25453@lists.php.net to get a copy of this message | ||
One hackish but slick use of array_flip() is to reduce an array to only its unique values. An
example:
<?php
$a[0] = "Tom";
$a[1] = "Tom";
$a[2] = "Dick";
$a[3] = "Dick";
$a[4] = "Harry";
$trans = array_flip($a);
$a = array_flip($trans);
?>
Since array offsets must be unique, duplicates will be blown away.