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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T05:00:42+00:00 2026-06-06T05:00:42+00:00

I am exploding an array appending it and then I am imploding the array

  • 0

I am exploding an array appending it and then I am imploding the array back. Everything works fine but I got a small doubt. Please take the example below.

$x = "123,456,789"
explode (' ', $x);
$x[] = "987";
implode (',', $x);

The output looks like the following :

,123,456,789,987

The problem is that the comma appears before the values. I want them to appear after just like the following

123,456,789,987,
  • 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-06T05:00:44+00:00Added an answer on June 6, 2026 at 5:00 am
    $x = '123,456,789'; // use ' instead " (just for performance)
    $x = explode (',', $x);
    $x[] = '987';
    $y = implode (',', $x);
    
    echo $y . ','; // add trailing comma (what nickb said)
    
    // output: 
    123,456,789,987,
    

    About the single vs double quotes issue please refers to PHP strings and Is there a performance benefit single quote vs double quote in php?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

rand(1,N) but excluding array(a,b,c,..) , is there already a built-in function that I don't
so I've made a clock-time to seconds function, and it works fine when running
I'm receiving a string a=100,b=20,c=20; for instance I know exploding this into an array
I'm trying to get random values out of an array and then break them
Are there any functions for recursively exploding and imploding multi-dimensional arrays in PHP?
I want to combine two array's, excluding duplicates. I am using a custom class:
I've been playing around with Bouncy Castle's implementation of RSA (Lightweight API) and got
I'm exploring the file upload and text parsing capabilities of PHP, but my first
There is array of objects, which are expanded with parallel ajax requests. When last
I have filled a dynamic allocated float multi array in a function. A second

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.