Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:94975 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 18577 invoked from network); 9 Aug 2016 18:38:31 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Aug 2016 18:38:31 -0000 Authentication-Results: pb1.pair.com smtp.mail=david.proweb@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=david.proweb@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.182 as permitted sender) X-PHP-List-Original-Sender: david.proweb@gmail.com X-Host-Fingerprint: 209.85.216.182 mail-qt0-f182.google.com Received: from [209.85.216.182] ([209.85.216.182:35709] helo=mail-qt0-f182.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 73/A6-03404-7232AA75 for ; Tue, 09 Aug 2016 14:38:31 -0400 Received: by mail-qt0-f182.google.com with SMTP id x25so10015792qtx.2 for ; Tue, 09 Aug 2016 11:38:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=k6C6djpY4+nwgy4QTYyBtzvOTgmaOX7C5heeCH3SQoA=; b=iVZh8YX5dt/Wz6o2oLL7xT2PrpM8X7wcgghzR5ApfPJTtuoNojS3kPx2/mn2YeozXL O7bVfpmF+PYyy7jlJeReRLZakeZrrSt/b/BF2H/lsJRG8i6vZLrysoGEILYN2vUtGQVO T010AatMRqwDo8cZdBW3aBqm55TQezeNRETucIozqxwNUkH+VUJbRJKF8zdqyTAMmOjt m3LoQR+kyP7Yd/4w1jGuzyIl4PrKMg030pIY3Ba30CsnIvb9JkigqXKNW7MnFqgXxQql sB2DK1SW9nbbZgF1zblcsZnmu002RcLN7va1Dh81+zr8BnPjW2otp9j/Hqtz1FZGejIp /NNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=k6C6djpY4+nwgy4QTYyBtzvOTgmaOX7C5heeCH3SQoA=; b=dKAIbG/LLMl2ZETvh7HHzxnZp8oeVcKdIQdB2xcuJcfBrqEZBAu6+eXMYVlEOy7C3u m/tLzyok7V0Zkvos1LCX2FRb/+KvMF0Mubo5rQ4+q4hP6V7uo34WULyYa4DZGJyRBTYt gjdaXi2WVzgADhA2EjnVGMicCirCDq8CmbEbDAlxIbsUVb1smEwgzbYyx0qS0X65OhPI yt5m2dn1nhABtf+B62BWlJlTPE3hOG/el1qveWKRjM7aA4R+u9aUlPY/nh5ma7r3lIYR 5SnupSFrZwXOfPFz9ley1eaHsoE7IEuoQbVDn8Oko2BZEoBER5/Zo/1azeKnTj+kCgu6 8oLg== X-Gm-Message-State: AEkooutwM4NNdjIdWXSlUkNwycCwcVettgHVyXLLyhjJmqGvvijMjf7mQONVDBLsDfTq4Iou6GP08CzNnSU2PA== X-Received: by 10.200.50.199 with SMTP id a7mr36655239qtb.43.1470767908779; Tue, 09 Aug 2016 11:38:28 -0700 (PDT) MIME-Version: 1.0 Received: by 10.55.45.67 with HTTP; Tue, 9 Aug 2016 11:38:08 -0700 (PDT) In-Reply-To: References: Date: Tue, 9 Aug 2016 15:38:08 -0300 Message-ID: To: Sara Golemon Cc: PHP Internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Method compare() From: david.proweb@gmail.com (David Rodrigues) Sara Golemon wrote: > Anything written in PHP could be written in C, the question you need > to answer isn't "How?", it's "Why?". Sure. In general, I just thinking about how it can be useful to iterate over values on a library itself. Laravel, for instance, have method Collection::where(), but it currently doesn't accepts an operator, although it should be very useful. It could be implemented like it: function where($index, $value, $operator = '==') { return array_filter($this->array, function ($arrayValue, $arrayIndex) use ($index, $value, $operator) { return compare($arrayValue[$index], $value, $operator); }); } $collection->where('id', 1, '>'); Currently it could be done by using "filter" and writing an user-defined function with > usage. But the problem is when this condition is client-defined, not developer-defined. For instance: In this case, I should implements a switch, where a compare() should works fine. -- David Rodrigues