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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:43:28+00:00 2026-05-20T11:43:28+00:00

In terms of my data structure, I have an array of communications, with each

  • 0

In terms of my data structure, I have an array of communications, with each communications_id itself containing three pieces of information: id, score, and content.

I want to implode this array in order to get a comma separated list of ids, how do I do this?

  • 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-20T11:43:29+00:00Added an answer on May 20, 2026 at 11:43 am

    Update for PHP 5.5

    PHP 5.5 introduces array_column which is a convenient shortcut to a whole class of array_map usage; it is also applicable here.

    $ids = array_column($communications, 'id');
    $output = implode(',', $ids);
    

    Original answer

    You need to make an array of just ids out of your array of communications. Then the implode would be trivial.

    Hint: the function for that is array_map.

    Solution:

    Assumes PHP 5.3, otherwise you ‘d have to write the callback as a string.

    $ids = array_map(function($item) { return $item['id']; }, $communications);
    $output = implode(',', $ids);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have doubt about data structure transformation from one form of array to another.
Does the Priority Queue data structure follow the set theory in terms of the
I am trying to think data in terms of sets but have some questions
I'm looking for the proper data structure for this scenario. I have boost available
In terms of performance and the data structure created, is: function coords(xpos, ypos, zpos){
In simple terms I have a form which has three identical entry fields. The
I am building a tree-like data structure out of associative arrays. Each key is
I have a dictionary data structure that must be passed around using WCF. To
The data.table package is very helpful in terms of speed. But I am having
Really my question is, if I were to use a nested data structure in

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.