The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Pass array into function Re: Pass array into function


While I’m not sure what you want to do, there a re a few ways to handle an unknown number of arguments.

You could use the func_get_args() function which is used like:

function my_function() {
$args = func_get_args();
foreach($args as $val) {
echo $val;

my_function(1, 2, 3, 4); --> 1234

Another way is restricting to associative array, so you have named values.

function my_function($array) {
if(isset($exclude)) {

$array = array('exclude'=>'1, 2, 3');

I’m not much of a WordPress person but it seems many of the arguments are passed name/value pairs as string, so you’d need to build some of those strings.

I have no idea if I helped here.