Re: [PHP] removing all duplicate values from an array
From: Mike Migurski (mike_at_saturn5.com)
Date: 10/30/03
- Next message: Cal: "NEWB: Getting a form <select> to activate"
- Previous message: Jackson Miller: "OOP, dynamic class extention"
- In reply to: Allowee: "removing all duplicate values from an array"
- Next in thread: Mike Migurski: "Re: [PHP] removing all duplicate values from an array"
- Reply: Mike Migurski: "Re: [PHP] removing all duplicate values from an array"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 30 Oct 2003 09:59:03 -0800 (PST) To: Allowee <Vincent@GeversXL.nl>
>I'm looking for a function that does almost the same as array_unique()
>
>But it must also delete the other duplicate entry.
<snip>
Untested pseudo-PHP follows -
$encountered_elements = array();
foreach($original_array as $key => $val)
if(in_array($val, $encountered_elements)) {
unset($original_array[$key]);
} else {
$encountered_elements[$key] = $val;
}
---------------------------------------------------------------------
michal migurski- contact info and pgp key:
sf/ca http://mike.teczno.com/contact.html
- Next message: Cal: "NEWB: Getting a form <select> to activate"
- Previous message: Jackson Miller: "OOP, dynamic class extention"
- In reply to: Allowee: "removing all duplicate values from an array"
- Next in thread: Mike Migurski: "Re: [PHP] removing all duplicate values from an array"
- Reply: Mike Migurski: "Re: [PHP] removing all duplicate values from an array"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]