Solved

Is it possible to return 2 things in PHP?

Posted on 2008-06-16
2
193 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
Comment Utility
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
Comment Utility
i see
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

744 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now