note 64710 added to function.array-unique
| From: | davin at baragiotta dot org | Date: | Wed, 19 Apr 2006 22:52:46 +0000 |
| Subject: | note 64710 added to function.array-unique | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-108707@lists.php.net to get a copy of this message | ||
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
----
Server IP: 216.235.15.211
Probable Submitter: 199.84.140.26
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.array-unique.php
Edit -- http://master.php.net/note/edit/64710
Del: integrated -- http://master.php.net/note/delete/64710/integrated
Del: useless -- http://master.php.net/note/delete/64710/useless
Del: bad code -- http://master.php.net/note/delete/64710/bad+code
Del: spam -- http://master.php.net/note/delete/64710/spam
Del: non-english -- http://master.php.net/note/delete/64710/non-english
Del: in docs -- http://master.php.net/note/delete/64710/in+docs
Del: other reasons-- http://master.php.net/note/delete/64710
Reject -- http://master.php.net/note/reject/64710
Search -- http://master.php.net/manage/user-notes.php