Bug #73427 [NEW]: Unintended behaviour of intersection functions
| From: | turabgarip at gmail dot com | Date: | Mon, 31 Oct 2016 08:14:36 +0000 |
| Subject: | Bug #73427 [NEW]: Unintended behaviour of intersection functions | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-205097@lists.php.net to get a copy of this message | ||
From: turabgarip at gmail dot com
Operating system: Windows
PHP version: 5.6.27
Package: Arrays related
Bug Type: Bug
Bug description:Unintended behaviour of intersection functions
Description:
------------
Intersection functions intend to compute the intersection of two or more
arrays; but they try to compare the elements of the individual array
itself. This is contradictory to the logic of intersection. Thus it
makes the intersection functions considerably slow.
In the test script, there are two arrays. Intersection will start to
compare from the first three colors like; "blue" to "green", "black"
to
"blue"; that are, the elements of the first array only; which are
actually very unnecessary to compare. Because the actual intention is to
compute the intersection of the two arrays; not the intersection of the
elements of the array itself. However an array can contain only one
identical element at once anyway, so it's useless and resource consuming
to check the array's own elements against each other.
Test script:
---------------
$arr1 = array('green', 'blue', 'black');
$arr2 = array('yellow', 'red', 'cyan');
array_intersect($arr1, $arr2);
Expected result:
----------------
Intersection function should compare the elements of the given arrays
crosswise.
--
Edit bug report at https://bugs.php.net/bug.php?id=73427&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=73427&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=73427&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=73427&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=73427&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=73427&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=73427&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=73427&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=73427&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=73427&r=support
Expected behavior: https://bugs.php.net/fix.php?id=73427&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=73427&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=73427&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=73427&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=73427&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=73427&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=73427&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=73427&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=73427&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=73427&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=73427&r=mysqlcfg