Is it possible to have a function with two returns like this:
function test($testvar)
{
// Do something
return $var1;
return $var2;
}
<
For PHP 7.1.0 onwards, you can use the new syntax (instead of the list function):
/**
* @return array [foo, bar]
*/
function getFooAndBar(): array {
return ['foo', 'bar'];
}
[$foo, $bar] = getFooAndBar();
print 'Hello '. $foo . ' and ' . $bar;
It's OK for me if you want to return 2-3 variables, otherwise you should use an object with the desired properties.