Re: anyway to return more than one value?
| From: | Boyan Nedkov | Date: | Thu, 06 Nov 2003 01:16:47 +0000 |
| Subject: | Re: anyway to return more than one value? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-168644@lists.php.net to get a copy of this message | ||
[snip]
... Someone also suggested I use a new class. Sounds like a good idea, but might be overkill for what I'm doing.[/snip] .. if you spend some time moving closer to the object oriented approach (php classes in this case) you may find that the development could be much more clear and easy ... and then will never come back to the functional/procedural way of programming -- Chris W. Parker wrote: > 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/ >