jmurch Posted January 13, 2007 Share Posted January 13, 2007 Hi, I have a form with checkboxes populating an array. When I pass the array to the action I want to concatonate the array contents to the rest of the $message. Code is below but I keep getting errors:The code that works fine exploding the array is:while (list ($key,$val) = @each ($market_segment)) { echo "$val, "; }I want to concatonate the contents of the array here so that I can include it my $message:$message .= "Product interested in: $product_interested_in\n";$message .= "Market segment: $market\n";$message .= "Geographic locations: $geographic_locations\n";I've tried all sorts of stuff and just keep getting an error. I'd like to put the entire contents into a variable $market as a sting such as:$market = while (list ($key,$val) = @each ($market_segment)) { echo "$val, "; }So that echo $market would produce a string of the values in the array seperated by ", ". It seems like I'm going in circles trying to do this.Thanks in advance for answers as to what I'm missing.Jeff Quote Link to comment Share on other sites More sharing options...
taith Posted January 13, 2007 Share Posted January 13, 2007 i think your looking for implode()[code]$string=implode(", ",$array);[/code] Quote Link to comment Share on other sites More sharing options...
jmurch Posted January 13, 2007 Author Share Posted January 13, 2007 Thanks Taith that did the trick. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.