From:             
Operating system: 
PHP version:      5.3.8
Package:          Arrays related
Bug Type:         Feature/Change Request
Bug description:Request for array subtraction operator.

Description:
------------
The manual page http://www.php.net/manual/en/language.operators.array.php
describes several operators available which work on array variables. This
includes the addition (+) operator, which allows us to merge two arrays.

I would suggest that a subtraction operator would also be useful.

For example, let us say we have two arrays, one of which is a full list of
available items, and the other is a list of items which have been used, and
I want to find the list of items which haven't been used. An array
subtraction operator would help with this.

Test script:
---------------
<?php
//suggested use for array subtraction operator.

$full_list = array('de'=>'some data', 'gr'=>'some data', 'tt'=>'some
data'); //etc...
$used_list = array('gr'=>'some data'); //etc...

$unused_list = $full_list - $used_list; //would contain 'de' and 'tt', but
not 'gr'.
?>

Expected result:
----------------
$unused_list would contain the array elements from $full_list minus those
present in $used_list. In the example code, this would mean $unused_list
would contain 'de' and 'tt', but not 'gr'.


Actual result:
--------------
This is a feature suggestion, so the above code does not currently run.

-- 
Edit bug report at https://bugs.php.net/bug.php?id=55505&edit=1
-- 
Try a snapshot (PHP 5.4):            
https://bugs.php.net/fix.php?id=55505&r=trysnapshot54
Try a snapshot (PHP 5.3):            
https://bugs.php.net/fix.php?id=55505&r=trysnapshot53
Try a snapshot (trunk):              
https://bugs.php.net/fix.php?id=55505&r=trysnapshottrunk
Fixed in SVN:                        
https://bugs.php.net/fix.php?id=55505&r=fixed
Fixed in SVN and need be documented: 
https://bugs.php.net/fix.php?id=55505&r=needdocs
Fixed in release:                    
https://bugs.php.net/fix.php?id=55505&r=alreadyfixed
Need backtrace:                      
https://bugs.php.net/fix.php?id=55505&r=needtrace
Need Reproduce Script:               
https://bugs.php.net/fix.php?id=55505&r=needscript
Try newer version:                   
https://bugs.php.net/fix.php?id=55505&r=oldversion
Not developer issue:                 
https://bugs.php.net/fix.php?id=55505&r=support
Expected behavior:                   
https://bugs.php.net/fix.php?id=55505&r=notwrong
Not enough info:                     
https://bugs.php.net/fix.php?id=55505&r=notenoughinfo
Submitted twice:                     
https://bugs.php.net/fix.php?id=55505&r=submittedtwice
register_globals:                    
https://bugs.php.net/fix.php?id=55505&r=globals
PHP 4 support discontinued:          
https://bugs.php.net/fix.php?id=55505&r=php4
Daylight Savings:                    https://bugs.php.net/fix.php?id=55505&r=dst
IIS Stability:                       
https://bugs.php.net/fix.php?id=55505&r=isapi
Install GNU Sed:                     
https://bugs.php.net/fix.php?id=55505&r=gnused
Floating point limitations:          
https://bugs.php.net/fix.php?id=55505&r=float
No Zend Extensions:                  
https://bugs.php.net/fix.php?id=55505&r=nozend
MySQL Configuration Error:           
https://bugs.php.net/fix.php?id=55505&r=mysqlcfg

Reply via email to