Forums

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

Home Forums Back End PHP define function as array Re: PHP define function as array

#59416

Not sure. You can pass an array to a php function and access it like any array.

Code:
$arr = array(“one”, “two”, “three”);

help($arr);

function help($args) {
foreach ($args as $arg) {
echo $arg . “n”;
}
}

Or you can access the list of passed variables using fung_get_args().

Code:
help2(“one”, “two”, “three”);

function help2() {
foreach( func_get_args() as $arg) {
echo $arg . “n”;
}
}