Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:70060 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 33445 invoked from network); 7 Nov 2013 13:33:01 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Nov 2013 13:33:01 -0000 Authentication-Results: pb1.pair.com smtp.mail=inefedor@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=inefedor@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.51 as permitted sender) X-PHP-List-Original-Sender: inefedor@gmail.com X-Host-Fingerprint: 209.85.215.51 mail-la0-f51.google.com Received: from [209.85.215.51] ([209.85.215.51:40521] helo=mail-la0-f51.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2C/50-31766-C869B725 for ; Thu, 07 Nov 2013 08:33:00 -0500 Received: by mail-la0-f51.google.com with SMTP id ep20so427454lab.24 for ; Thu, 07 Nov 2013 05:32:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=content-type:to:date:subject:mime-version:content-transfer-encoding :from:message-id:user-agent; bh=ccy5mZMTWR14J+SAkMAgDsBkIxzj03kJcEyiIwecy9M=; b=wMEEOpMpmEYLgYFHySKRbtpjuGdI4JxAfJsz0eeMgrQMZgFvOqq2/VEsrEN4+mQTpv KCTvvludHnb6+xXe0mfNZwUibKM27pzkGgJbfzqOvosU5ZmNZXTF2DwM3S5DT5ih0cHa Iye2OUkG1ldH7jLulsmm+YGdfFeAiQwCtBpFXtQeX44JbsclhKPrnpegOfQPkvmLcRYy mW/0A+V1hp4iBusORmW1tz8Hntoyt8EvogaaokmsEQdAaQGDSkihMP6Tliic//3khX8E 1fw9m7hTPb2qSCCGwQlBEeMEyFJ9HFqSytCmoPy/6+WmvtBPlpwL/OgyY3qdpFFCfwqU Uaqg== X-Received: by 10.112.128.166 with SMTP id np6mr6495633lbb.7.1383830687385; Thu, 07 Nov 2013 05:24:47 -0800 (PST) Received: from nikita2206-n56vj ([217.174.184.92]) by mx.google.com with ESMTPSA id b1sm3456041lah.6.2013.11.07.05.24.46 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 07 Nov 2013 05:24:46 -0800 (PST) Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes To: "internals@lists.php.net" Date: Thu, 07 Nov 2013 17:24:44 +0400 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Message-ID: User-Agent: Opera Mail/12.16 (Linux) Subject: array_unique optional compare-callback proposal From: inefedor@gmail.com ("Nikita Nefedov") Hello, I would like to propose addition of a third (optional) argument for array_unique which will be callback for comparing elements. There's a plenty of usecases for this. For example, what I've been dealing with can be described like so: getWrappedObject()->getIdentity()] = $e; } // but with this patch it can be solved with array_unique: $newArray = array_unique($a, SORT_USERDEFINED, function ($a, $b) { return $a->getWrappedObject()->getIdentity() - $b->getWrappedObject()->getIdentity(); }); Actually my problem was a little different but you get the idea... And I think there will be even more usecases for this. Here's a patch for master branch with implementation of this proposal: https://gist.github.com/nikita2206/7354392