Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116547 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 69272 invoked from network); 1 Dec 2021 12:57:37 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 1 Dec 2021 12:57:37 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 8D78D1801FD for ; Wed, 1 Dec 2021 05:56:19 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS24940 78.46.0.0/15 X-Spam-Virus: No X-Envelope-From: Received: from mail.webkr.de (mail.webkr.de [78.47.173.34]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 1 Dec 2021 05:56:18 -0800 (PST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 0731E1A0D96 for ; Wed, 1 Dec 2021 14:56:15 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=webkr.de; s=dkim; t=1638366976; h=from:subject:date:message-id:to:mime-version:content-type: content-transfer-encoding; bh=37rJmBMAmVnBHsagp1kEppnX4hw+SzY9I8ma1XR9Vjg=; b=J6yA0LopkVK9sQ/yJwzVX0kC+qZfuY6iF58XN4lAv9PE2wfoShYRKFloj/4gWmTnxgRj2b mQeWFnz/QDUsO6f5XeCfjg69q94mBbIHkIvJID0oxoqZqw4TK9k+P0raBDNWzVZWXnvaVW uk8m0GFt4kux7sLSP90RWOkVSzvH/a4= To: Date: Wed, 1 Dec 2021 14:56:07 +0100 Message-ID: <087101d7e6bb$30f27d70$92d77850$@webkr.de> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Language: de Thread-Index: AdfmuYApeGDTVzCWRpW9yH4qTPFmeg== X-Last-TLS-Session-Version: TLSv1 Subject: Array comparison works completely different than documented? From: andre@webkr.de (=?iso-8859-1?Q?Andr=E9_H=E4nsel?=) The official documentation contains a conceptual description of array comparison in https://www.php.net/manual/en/language.operators.comparison.php#example-113. Curiously the people who wrote the inofficial spec (I think the HHVM team at Facebook?) came to pretty much the same result, described in https://github.com/php/php-langspec/blob/master/spec/10-expressions.md#relat ional-operators: > If both operands have array type, if the arrays have different numbers of elements, the one > with the fewer is considered less-than the other one, regardless of the keys and values in each, > and the comparison ends. For arrays having the same numbers of elements, the keys from the left > operand are considered one by one, if the next key in the left-hand operand exists in the > right-hand operand, the corresponding values are compared. If they are unequal, the array > containing the lesser value is considered less-than the other one, and the comparison ends; > otherwise, the process is repeated with the next element. If the next key in the left-hand > operand does not exist in the right-hand operand, the arrays cannot be compared and FALSE is > returned. If all the values are equal, then the arrays are considered equal. In reality, array comparison works completely different, it is however unclear to me how exactly it does work: https://3v4l.org/630vG Do we know how this happened?