how to dynamically generate list of arguments to pass to array_diff

From: Date: Fri, 18 Feb 2011 19:07:56 +0000
Subject: how to dynamically generate list of arguments to pass to array_diff
Groups: php.general 
Request: Send a blank email to php-general+get-311427@lists.php.net to get a copy of this message
Hello, I have an array of arrays like this: --- [array_of_arrays:private] => Array ( [0] => Array ( [0] => 2 [1] => 4 [2] => 5 [3] => 17 [4] => 80 ) [1] => Array ( [0] => 5 [1] => 7 [2] => 9 [3] => 2 [4] => 16 [5] => 58 ) [2] => Array ( [0] => 2 [1] => 4 [2] => 6 [3] => 8 [4] => 37 [5] => 92 ) ) --- and I want to do an array_diff on them so that I get something like this back: --- Array ( [0] => 6 [1] => 7 [2] => 8 [3] => 9 [4] => 16 [5] => 17 [6] => 37 [7] => 58 [8] => 80 [9] => 92 ) --- The arrays above are just an example; the real arrays I am working with can have many more elements (in the tens of thousands). Also, there can be a variable number of subarrays. I have written several different versions of my own array_diff that iterates over all the subarrays but they are slow. My question is is there a way to call the built-in array_diff with a dynamically generated list of arguments? I was thinking maybe there would be a way to do this with variable variables or if I generated a string that could be parsed by PHP but I have only succeeded in confusing myself further. Thanks for any suggestions. Mari

« previous php.general (#311427) next »