Re: <- functions returning multiple values Followup
| From: | Jerry Artman | Date: | Sat, 27 Jan 2001 02:26:00 +0000 |
| Subject: | Re: <- functions returning multiple values Followup | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-36948@lists.php.net to get a copy of this message | ||
Would it be easier to return an OBJECT populated with all the items one
might need?
On 01/22/2001 12:38 PM, "Matt McClanahan" <cardinal@dodds.net> wrote:
> On Mon, 22 Jan 2001, Abe Asghar wrote:
>
>> Hey there,
>>
>> is there a way that you can get a function to return multiple values. e.g.:
>> {and also how to access them}
>>
>> function VarTest() {
>>
>> return $var = 10;
>>
>> return $var2 = 20;
>> }
>
> Functions can only return one variable. However, you can return an array,
> which contains as many values as you need.
>
> function vartest()
> {
> $first = 10;
> $second = 20;
>
> return Array($first,$second);
> }
>
> Matt
>
>