anyway to return more than one value?

From: Date: Thu, 06 Nov 2003 00:02:03 +0000
Subject: anyway to return more than one value?
Groups: php.general 
Request: Send a blank email to php-general+get-168631@lists.php.net to get a copy of this message
Hi list. Ok I know it's not possible to "return" more than one value. But I'm going to explain what I'd like to do so maybe there's an easy way to do it. I've got some functions that query a database and turn the result into an array and return that array. What I'd like to do is not only return the array of results but ALSO return a row count and field count of that result. Here is some pseudo code: function get_results() { // query database $result = query($sql); // turn result set into a useable array $theResultArray = get_results($result); $rows = mysql_num_rows($result); $fields = mysql_num_fields($result); return $theResultArray; return $rows; return $fields; } Ok I know that won't work but that's just basically what I want to do. The only way around this I've come up with is to stick all the values into ANOTHER array and return then and then dissect that array in the calling function, but that just seems messy. All of a sudden the word "reference" came to mind. Is that what I want to use? Any help would be appreciated. Thanks, Chris. -- Don't like reformatting your Outlook replies? Now there's relief! http://home.in.tum.de/~jain/software/outlook-quotefix/

« previous php.general (#168631) next »