there are two ways of achieving this

1. Pass the arguments by reference and you will have their latest values
after the function call.

look up the manual http://www.php.net/manual/en/language.references.php

2. Create an array in the function with the various values to be returned
stored as its elements and then return the array. The array will then have
multiple return values in its elements after the function is called.

hope that helps

regards

Ankur Verma
HCL Technologies
A1CD, Sec -16
Noida, UP
India


----- Original Message -----
From: "James, Yz" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, February 13, 2001 2:43 AM
Subject: [PHP] returning multiple variables from a function?


> Hrms.  Got a small problem.
>
> I'm now using functions on a regular basis, but I've come to another
> sticking point with them:  returning multiple variables from the
function...
>
> Here's a really quick example (nothing to do with what I intend to use the
> functions for):
>
> function CUP ($connection,$username,$password) {
>
>     if (($username) && ($password)) {
>         $sql = "SELECT username, password FROM table
>             WHERE username = '$username' AND password = '$password'";
>         $result = etc etc
>         $num = mysql_numrows($result);
>
>         if ($num != 0) {
>             $valid = "yes";
>         }
>
>     return $valid;
>
> }
>
>
>
> $correct_user = CUP ($connection,$username,$password);
>
> Now, if the user is correct, I'd get a return of
>
> $correct_user = "yes";
>
> What if I wanted to "return" more than one variable from the function?
And
> how would I assign it a name?  Like the actual variable, or is that just
not
> possible?
>
> I've tried
> return $var1,$var2;
> But got an error.
>
> As always, tia :)
>
> James.
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to