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 935973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:14:27+00:00 2026-05-15T21:14:27+00:00

Sorry if this is confusing. It’s tough for me to put into words having

  • 0

Sorry if this is confusing. It’s tough for me to put into words having beginner knowledge of PHP.

I’m using the following foreach loop:

foreach ($_POST['technologies'] as $technologies){
    echo ", " . $technologies;
}

Which produces:

, First, Second, Third

What I want:

First, Second, Third

All I need is for the loop to skip the echo ", " for the first key. How can I accomplish that?

  • 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-05-15T21:14:27+00:00Added an answer on May 15, 2026 at 9:14 pm

    You can pull out the indices of each array item using => and not print a comma for the first item:

    foreach ($_POST['technologies'] as $i => $technologies) {
        if ($i > 0) {
            echo ", ";
        }
    
        echo $technologies;
    }
    

    Or, even easier, you can use implode($glue, $pieces), which “returns a string containing a string representation of all the array elements in the same order, with the glue string between each element”:

    echo implode(", ", $_POST['technologies']);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry if the title sounds confusing - but this is what I am trying
Sorry about the confusing title. I recently started doing this in my project, and
I'm sorry if the title is a bit confusing, but this is my problem:
I'm sorry if this is confusing but in my layouts/application.html.erb I have several links,
Sorry if this question is confusing. I have inherited a site that is already
Sorry but this is really confusing me and I know the answer is staring
Sorry if this a completely nube sounding questioning. I'm new to the PHP syntax
Sorry for confusing the topic, this was the original question: How to reallocate an
Sorry if the title to this post is a bit confusing. My question is
Sorry this is not a very well defined question, I am thinking about an

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.