Jump to content

Help. Convert array contents to string


jmurch

Recommended Posts

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
Link to comment
https://forums.phpfreaks.com/topic/34037-help-convert-array-contents-to-string/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.