Bug->Req #73232 [Opn]: Array ordering is inconsistant.

From: Date: Wed, 18 Aug 2021 15:42:32 +0000
Subject: Bug->Req #73232 [Opn]: Array ordering is inconsistant.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-235944@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=73232&edit=1 ID: 73232 Updated by: cmb@php.net Reported by: robin at patenall dot org dot uk Summary: Array ordering is inconsistant. Status: Open -Type: Bug +Type: Feature/Change Request Package: Arrays related Operating System: Centos PHP Version: 7.0.11 Block user comment: N Private report: N New Comment: Re-classifying as feature request as per my comment above. Previous Comments: ------------------------------------------------------------------------ [2018-03-18 11:42:13] cmb@php.net The problem here is that the result of the comparison depends on which array is the "first" array: hence $a < $b and $b < $a. However, the engine assumes that $a > $b is equivalent to $b <= $a, which is certainly a false assumption with regard to array comparisons. We most certainly could fix this, and although the results would match the documentation then, they still would not make much sense. Besides, the resulting BC break would be an issue. It seems to me this issue deserves some discussion on the internals@ mailing list. ------------------------------------------------------------------------ [2018-02-19 13:45:47] rolf at rolfjentsch dot de I can only excuse my self. I thought that a missinterpreting of >= lead o the problem. As you clearly stated it's not to use <? as a start tag as i did. (which is not stated in the germen documentation) That my posted source has a problem from improper syntax is also a benefit for me ... but it worked for years without someone complaining or leading not to the desired result ------------------------------------------------------------------------ [2018-02-19 12:48:39] spam2 at rhsoft dot net why do you come with the same broken snippet as in https://bugs.php.net/bug.php?id=75980 on this topic? your code is simply broken because you don't understand how weak-typing works when return value of a boolean false is completly different meaning then int 0 ------------------------------------------------------------------------ [2018-02-19 12:32:58] rolf at rolfjentsch dot de if (isset($_SERVER['SERVER_ADDR'])) { if (strpos($_SERVER['SERVER_ADDR'],"192.168.10") >= 0) { $where="http://qnap/piwik/"; } else { $where="https://www.someurl/piwik/"; } } else $where="https://someurl/piwik/"; Problem arrises when >= is processed ------------------------------------------------------------------------ [2016-10-03 18:29:10] robin at patenall dot org dot uk Based on the 'Transcription of standard array comparison' example on the php Comparison Operators page I'd expect var_dump($b < $a) to be true and var_dump($b > $a) to be false as $b['a'] < $a['a']. In the same way that var_dump($a < $b) should be true and var_dump($a > $b) should be false as $a['b'] < $b['b']. This does make array ordering comparison not commutative, but that's what the documentation say. It also means that in no case are var_dump($a < $b) and var_dump($a > $b) both equal to true. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=73232 -- Edit this bug report at https://bugs.php.net/bug.php?id=73232&edit=1

« previous php.bugs (#235944) next »