Re: using foreach() to capture multiple selections

From: Date: Tue, 21 Sep 2004 20:21:18 +0000
Subject: Re: using foreach() to capture multiple selections
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-197481@lists.php.net to get a copy of this message
Luke Mackenzie wrote:
Subject: using foreach() to capture multiple selections hi, i would like to to put multiple selections from a form list into a single variable using foreach but am unsure how to do so. can someone advise how to adapt the following code? <?php print "You are interested in: "; foreach($myGoals as $value) { print "$value "; } ?> I'm not totally sure what you are looking for. It looks like you have values in an array $myGoals. I'm assuming you collected the form values in the array, so you have $myGoals[0], $myGoals[1], etc. Are you saying you want all the values in MyGoals added to a single variable as a string? If so, look at the function implode. www.php.net/manual/en/function.implode.php
Or, you can have a statement in your forrach loop something like: $string .= $value." "; Janet
--------------------------------- lukem - quality custom t-shirts browse - www.lukem.co.uk contact- info@lukem.co.uk need a new website? get over to http://www.lukem-sites.co.uk <http://www.lukem-sites.co.uk/>


« previous php.general (#197481) next »