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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.