note 64710 deleted from function.array-unique by danbrown

From: Date: Sun, 23 Jan 2011 17:23:43 +0000
Subject: note 64710 deleted from function.array-unique by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-176196@lists.php.net to get a copy of this message
Note Submitter: davin at baragiotta dot org ---- I used the code submitted by "agarcia" regarding multi-dimensional arrays but keys with no data were still there. I've just added a line to completely unset the redondant part of the array so it is now acting like array_unique. <?php function remove_dup($matriz) { $aux_ini=array(); $entrega=array(); for($n=0;$n<count($matriz);$n++) { $aux_ini[]=serialize($matriz[$n]); } $mat=array_unique($aux_ini); for($n=0;$n<count($matriz);$n++) { $entrega[]=unserialize($mat[$n]); } foreach ($entrega as $key => $row){ if (!is_array($row)) { unset($entrega[$key]); } } return $entrega; } ?> Thanks! Davin Baragiotta

« previous php.notes (#176196) next »