Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:68499 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 26834 invoked from network); 13 Aug 2013 10:15:17 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Aug 2013 10:15:17 -0000 X-Host-Fingerprint: 109.213.224.12 ALyon-654-1-392-12.w109-213.abo.wanadoo.fr Received: from [109.213.224.12] ([109.213.224.12:16754] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 24/05-06453-4370A025 for ; Tue, 13 Aug 2013 06:15:16 -0400 Message-ID: <24.05.06453.4370A025@pb1.pair.com> To: internals@lists.php.net Date: Tue, 13 Aug 2013 12:15:12 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130803 Thunderbird/17.0.8 MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 109.213.224.12 Subject: array_unique() and object comparison From: matthieu@mnapoli.fr (Matthieu Napoli) array_unique() is perfect for removing duplicates in a string array, but not so great for an array of objects. SORT_REGULAR was added to compare items without casting them to string. However it uses the "==" comparison operator. I see two improvements: - on a short term, improve the documentation to make it explicit that the "==" operator will be used (the example with "(string) $elem1 === (string) $elem2" is misleading, "===" should be replaced with "==") - on a long term, maybe add another option SORT_STRICT (like the $strict parameter for in_array): that sort would use the strict comparison operator "===" Any thoughts about that? Matthieu