I would like to return 2 different values with one function. These are my functions:
function example1 ($a) {
return $result1;
return $result2;
}
function example2 ($edit, $account, $value) {
$config ($edit);
}
Like this I get $result1 in my $config-variable. But what do I need to do to get both returned values in my example1-function?
This is probably the cleanest way to do this:
function example1($a)
{
return array($result1, $result2)
}
// get both values
list($config1, $config2) = example1($a);
This will make $config = $result1 and $config2 = $result2.
You can't return 2 variables in one function, you should return an array instead:
function example1 ($a) {
$result[0] = 'something';
$result[1] = 'something else';
return $result;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With