returning multiple variables from a function?

From: Date: Mon, 12 Feb 2001 21:13:09 +0000
Subject: returning multiple variables from a function?
Groups: php.general 
Request: Send a blank email to php-general+get-39263@lists.php.net to get a copy of this message
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.

« previous php.general (#39263) next »