Solved

Is it possible to return 2 things in PHP?

Posted on 2008-06-16
2
233 Views
Last Modified: 2008-06-16
Is it possible to return 2 things from a function in PHP?
0
Comment
Question by:mawingho
2 Comments
 
LVL 49

Accepted Solution

by:
Roonaan earned 500 total points
ID: 21791431
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
 

Author Comment

by:mawingho
ID: 21791454
i see
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This article discusses four methods for overlaying images in a container on a web page
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

761 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question