Re: strings in a function return

From: Date: Thu, 30 Aug 2001 10:03:45 +0000
Subject: Re: strings in a function return
References: 1 2 3 4 5  Groups: php.general 
Request: Send a blank email to php-general+get-65196@lists.php.net to get a copy of this message
<Original message> From: Gerard Samuel <trini0@optonline.net> Date: Wed, Aug 29, 2001 at 09:58:12PM -0400 Message-ID: <3B8D9DB4.10803@optonline.net> Subject: Re: [PHP] strings in a function return > I found an error, but it didn't do me any good. > I tried this, any tips... > Thanks > > function assign() { > global $adminurl, $string; > top(); > if ($string) { > $data = explode ("|", $string); > foreach ($data as $foo) { > echo $foo[0]; } > } > <form> > > $array = > array("$new_cat","$assigned_to","$job","$assigned_by"); > $string = implode("|",$array); > return $string; > } > > The variables that form $array are from the form.... </Original message> <Reply> Why use array("$new_cat",...,"$assigned_by"); Loose the quotes: array ($new_cat,...,$assigned_by); You don't need to use implode(). Just return the array. In the calling function you can then get the results in two ways: $results = assign(); /* $results is an array */ or list ($new_cat,...,$assigned_by) = assign(); If you want a better answer on what is going wrong, you'll need to send some more code. Eg the code that you've now replaced by <form>. It might just be that the error is in that part. </Reply> -- * R&zE: -- »»»»»»»»»»»»»»»»»»»»»»»» -- Renze Munnik -- DataLink BV -- -- E: renze@datalink.nl -- W: +31 23 5326162 -- F: +31 23 5322144 -- M: +31 6 21811143 -- -- Stationsplein 82 -- 2011 LM HAARLEM -- Netherlands -- -- http://www.datalink.nl -- ««««««««««««««««««««««««

« previous php.general (#65196) next »