note 23906 added to function.array-flip

From: Date: Wed, 31 Jul 2002 15:04:52 +0000
Subject: note 23906 added to function.array-flip
Groups: php.notes 
Request: Send a blank email to php-notes+get-34048@lists.php.net to get a copy of this message
Hi, here is a mean to delete duplicated entries in an array : $z = 0; $tab[$z++]="a"; $tab[$z++]="a"; $tab[$z++]="a"; $tab[$z++]="b"; $tab[$z++]="b"; $tab[$z++]="b"; $tab[$z++]="b"; $tab[$z++]="c"; $tab[$z++]="d"; $tab[$z++]="d"; $tab[$z++]="e"; $tab[$z++]="f"; $tab[$z++]="g"; $tab = array_flip(array_flip($tab)); print_r($tab); Array ( [2] => a [6] => b [7] => c [9] => d [10] => e [11] => f [12] => g ) then you can use foreach to get each value... I needed this because i use a function that generate block with different css sheet In order not to echo <LINK ...> two times with the same content, i find this easy programming (but not fast) way. Paquerette -- http://www.php.net/manual/en/function.array-flip.php http://master.php.net/manage/user-notes.php?action=edit+23906 http://master.php.net/manage/user-notes.php?action=delete+23906 http://master.php.net/manage/user-notes.php?action=reject+23906

« previous php.notes (#34048) next »