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- [EMAIL PROTECTED]
need a new website? get over to
http://www.lukem-sites.co.uk <http://www.lukem-sites.co.uk/>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php