Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8643961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:10:45+00:00 2026-06-12T12:10:45+00:00

I’ve only skimmed through, but I wanted to get my first question out here,

  • 0

I’ve only skimmed through, but I wanted to get my first question out here, seeing as I haven’t found a specific and similar example/inquiry.

I have on the ‘first page’ of a site many groups of varying companies. In each group are 1 – 20 or so check-boxed input fields so that a client can require different information be sent to them after they submit the form below. On a separate page that only runs a php script, I email the form to the host company. The message then displays as so: (and I changed content…)

I want it to read:

            *Favorite Animals: Dog, Cat, Bird*

However I have it reading:

            Favorite Animals: Dog,
            Favorite Animals: Cat,
            Favorite Animals: Bird,

My Code:

On the first page we have a list of different checkboxes in the same array with obvious different values… like shown below:

<input type="checkbox" name="animals[]" value="Dogs" class="cb">
 Dogs<br>
<input type="checkbox" name="animals[]" value="Cats" class="cb">
 Cats<br>
<input type="checkbox" name="animals[]" value="Birds" class="cb">
 Birds<br>
<input type="checkbox" name="animals[]" value="Dragons" class="cb">
 Dragons<br>

The above code is then submitted (via post) to a separate php document.

The relevant code in this second page is:

$animals = $_POST['animals'];

below…

    foreach ($animals as $an) {
$email_message .= "Favorite Animals: ".clean_string($an)." ,\n";
    }

I realize what’s going on, but I haven’t figured out a way to work the foreach statement so that the “Favorite Animal’s” is displayed once, followed by the possible array of whatever was selected on the previous page.

I have no errors, only getting the information in a way I don’t desire. Any help would be appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T12:10:46+00:00Added an answer on June 12, 2026 at 12:10 pm

    Just take the static parts outside the loop. That should do it.

     $email_message .= "Favorite Animals: ";
    
     foreach ($animals as $an) {
       $email_message .= clean_string($an)." ,";
     }
      $email_message = rtrim ($email_message, ",");
    
     $email_message .= "\n";
    
     // Continue appending rest of the email message
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This could be a duplicate question, but I have no idea what search terms
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I want to count how many characters a certain string has in PHP, but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I know there's a lot of other questions out there that deal with this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.