RE: [PHP] passing new variables back from a function

From: Date: Thu, 07 Sep 2000 14:06:51 +0000
Subject: RE: [PHP] passing new variables back from a function
Groups: php.general 
Request: Send a blank email to php-general+get-15712@lists.php.net to get a copy of this message
Hi, The "global variable" approach... function explode_var($varname) { global $name; global $valuecode; $vararray = explode(":", $varname); $name = $vararray['0']; $valuecode = $vararray['1']; } $name=""; $valuecode=""; explode_var($details); echo "name = $name"; > -----Original Message----- > From: Matt Williams [mailto:matt@yewlands.com] > Sent: 07 September 2000 15:08 > To: php-general@lists.php.net > Subject: [PHP] passing new variables back from a function > > > Hi > > I am trying to write a function that will split a string a > return the values > as new variables > Here's what I've got > > function explode_var($varname) > { > $vararray = explode(":", $varname); > $name = $vararray['0']; > $valuecode = $vararray['1']; > > } > > explode_var($details); > echo "name = $name"; > > But it does not output anything. If I put the echo inside the > function it > outputs correctly but I want to pass the variable back to the > script so /i > can do other stuff to it. > > Many thanks for any help > > M@ > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: > php-list-admin@lists.php.net > >

« previous php.general (#15712) next »