Is it possible to return 2 things in PHP?

Is it possible to return 2 things from a function in PHP?
mawinghoAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
RoonaanConnect With a Mentor Commented:
You would return an array:
function doMath($value1, $value2) {

  return array($value1+$value2, $value1 * $value2);
}

$return = doMath(1, 2);
$added = $return[0];
$multiplied = $return[1];

Or use:

list($added, $multiplied) = doMath(1,2);

Kind regards

-r-
0
 
mawinghoAuthor Commented:
i see
0
All Courses

From novice to tech pro — start learning today.