php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #55853 provide an array_diff equivalent for undetermined numbers of array
Submitted: 2011-10-05 17:32 UTC Modified: 2012-09-23 16:51 UTC
From: netmosfera at gmail dot com Assigned:
Status: Wont fix Package: Arrays related
PHP Version: Irrelevant OS: irrelevant
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: netmosfera at gmail dot com
New email:
PHP Version: OS:

 

 [2011-10-05 17:32 UTC] netmosfera at gmail dot com
Description:
------------
hi

if I have an undetermined number of array I can't use array_diff to get the differences

a function like: array_diff_array() would be really nice

<?php

$myarrays[] = array("a" => "green", "red", "blue", "red");
$myarrays[] = array("b" => "green", "yellow", "red");
// undetermined number of arrays

print_r(array_diff_array($myarrays));

?>

I think that the only way to do this now, is using eval!

thank you!



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-12-30 05:02 UTC] phristen at yahoo dot com
I agree, BUT this is opening a big can of worms because there are plenty other functions that could use the same treatment, like array_merge and the likes.
 [2012-09-23 16:51 UTC] nikic@php.net
You can already do this using call_user_func_array:

    $diff = call_user_func_array('array_diff', $arrays);
 [2012-09-23 16:51 UTC] nikic@php.net
-Status: Open +Status: Wont fix
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 14:01:32 2024 UTC