Re: [PHP] returning more than 1 value from function
Sorry ... busy morning ... I misplaced the & for the reference. They should be on the arguments on the function definiton, not the function call. Sorry if I caused any confusion. ~Chris /"\ \ / Microsoft Security Specialist: X The moron in Oxymoron. / \ http://www.thebackrow.net On Thu, 4 Jul 2002, Chris Wesley wrote: > On Thu, 4 Jul 2002, andy wrote: > > > i am wondering if it is possible to return more than 1 value from a > > function? > > You can pass your arguments by reference. > > function test( $arg1, $arg2 ){ > $arg1 = "foo"; > $arg2 = "bar"; > } > > $var1 = ""; > $var2 = ""; > > test( &$var1, &$var2 ); // Note the "&" before the arguments. > ?> > > The result will be that $var1 == "foo" and $var2 == "bar". > > You can mix it up too ... if you want the function to return a value (say, > true or false) AND modify arguments, modify only a subset of the > arguments, etc. > > (see http://www.php.net/manual/en/functions.arguments.php) > > g.luck, > ~Chris /"\ >\ / Microsoft Security Specialist: > X The moron in Oxymoron. >/ \ http://www.thebackrow.net > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] returning more than 1 value from function
On Thu, 4 Jul 2002, andy wrote: > i am wondering if it is possible to return more than 1 value from a > function? You can pass your arguments by reference. The result will be that $var1 == "foo" and $var2 == "bar". You can mix it up too ... if you want the function to return a value (say, true or false) AND modify arguments, modify only a subset of the arguments, etc. (see http://www.php.net/manual/en/functions.arguments.php) g.luck, ~Chris /"\ \ / Microsoft Security Specialist: X The moron in Oxymoron. / \ http://www.thebackrow.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] returning more than 1 value from function
On Thu, Jul 04, 2002 at 07:16:39PM +0200, andy wrote: > > i am wondering if it is possible to return more than 1 value from a > function? > > test(){ > return $value1, $value2 > } You can return an array. Or, you can global the variables and then set them to the values you want. --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] returning more than 1 value from function
hi there, i am wondering if it is possible to return more than 1 value from a function? something like test(){ return $value1, $value2 } Thanx for any help, Andy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php