note 5864 modified in array_flip by ronabop

From: Date: Wed, 18 Oct 2000 04:24:20 +0000
Subject: note 5864 modified in array_flip by ronabop
Groups: php.notes 
Request: Send a blank email to php-notes+get-6614@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. http://www.php.net/manual/function.array-flip.php

« previous php.notes (#6614) next »