note 28506 added to functions.returning-values
| From: | ian at NO_SPAM dot verteron dot net | Date: | Wed, 15 Jan 2003 10:28:35 +0000 |
| Subject: | note 28506 added to functions.returning-values | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-42168@lists.php.net to get a copy of this message | ||
In reference to the poster above, an additional (better?) way to return multiple values from a
function is to use list(). For example:
function fn($a, $b)
{
# complex stuff
return array(
$a * $b,
$a + $b,
);
}
list($product, $sum) = fn(3, 4);
echo $product; # prints 12
echo $sum; # prints 7
--
http://www.php.net/manual/en/functions.returning-values.php
http://master.php.net/manage/user-notes.php?action=edit+28506
http://master.php.net/manage/user-notes.php?action=delete+28506
http://master.php.net/manage/user-notes.php?action=reject+28506