Re: [SOLVED] [PHP] how to dynamically generate list of arguments to pass to array_diff
| From: | Mari Masuda | Date: | Fri, 18 Feb 2011 20:14:33 +0000 |
| Subject: | Re: [SOLVED] [PHP] how to dynamically generate list of arguments to pass to array_diff | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-311429@lists.php.net to get a copy of this message | ||
On Feb 18, 2011, at 12:03 PM, Simon J Welsh wrote:
>
> On 19/02/2011, at 8:07 AM, Mari Masuda wrote:
>> 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
>
> call_user_func_array('array_diff', $this->array_of_arrays);
>
> http://php.net/call_user_func_array
>
> Though from your example, passing multiple arrays to array_diff is not what you're after,
> as it just returns the items in the first array that are not in any of the others.
> ---
> Simon Welsh
> Admin of http://simon.geek.nz/
>
> Who said Microsoft never created a bug-free program? The blue screen never, ever crashes!
>
> http://www.thinkgeek.com/brain/gimme.cgi?wid=81d520e5e
>
Hi Simon,
Thank you for the info on call_user_func_array and for pointing out my error! (That bug would
partially explain why I have been beating my head against the wall for the last several days.)
call_user_func_array is exactly what I need. Thanks again!
Mari