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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:02:42+00:00 2026-06-01T11:02:42+00:00

Tech used: PHP 5.3.10 Hi, I have an array (example below) I need to

  • 0

Tech used: PHP 5.3.10

Hi, I have an array (example below) I need to manipulate by combining the same times, concat any applicable offerId’s to a comma delimted string and finally return the string sorted by time! Not much then 🙂

I looked at this answer to ID the rows: https://stackoverflow.com/a/1019534/260023 however I drew a blank once I had identified the row how to modily the data in it…

Array
(
[0] => Array
    (
        [dateTime] => 2012-04-03T18:00:00
        [offerIDs] => 
    )

[1] => Array
    (
        [dateTime] => 2012-04-03T18:30:00
        [offerIDs] => 
    )

[2] => Array
    (
        [dateTime] => 2012-04-03T19:00:00
        [offerIDs] => 
    )

[3] => Array
    (
        [dateTime] => 2012-04-03T21:00:00
        [offerIDs] => 
    )


[4] => Array
    (
        [dateTime] => 2012-04-03T18:00:00
        [offerIDs] => 17302
    )

[5] => Array
    (
        [dateTime] => 2012-04-03T18:30:00
        [offerIDs] => 17302
    )

[6] => Array
    (
        [dateTime] => 2012-04-03T19:00:00
        [offerIDs] => 17302
    )

[7] => Array
    (
        [dateTime] => 2012-04-03T19:30:00
        [offerIDs] => 17302
    )

[8] => Array
    (
        [dateTime] => 2012-04-03T20:00:00
        [offerIDs] => 17302
    )

[9] => Array
    (
        [dateTime] => 2012-04-03T20:30:00
        [offerIDs] => 17302
    )

[10] => Array
    (
        [dateTime] => 2012-04-03T19:00:00
        [offerIDs] => 17298
    )

)

This should result in:

Array
(
[0] => Array
    (
        [dateTime] => 2012-04-03T18:00:00
        [offerIDs] => 17302
    )

[1] => Array
    (
        [dateTime] => 2012-04-03T18:30:00
        [offerIDs] => 17302
    )

[2] => Array
    (
        [dateTime] => 2012-04-03T19:00:00
        [offerIDs] => 17302,17298
    )


[6] => Array
    (
        [dateTime] => 2012-04-03T19:30:00
        [offerIDs] => 17302
    )

[7] => Array
    (
        [dateTime] => 2012-04-03T20:00:00
        [offerIDs] => 17302


[8] => Array
    (
        [dateTime] => 2012-04-03T20:30:00
        [offerIDs] => 17302
    )

[9] => Array
    (
        [dateTime] => 2012-04-03T21:00:00
        [offerIDs] => 
    )
)
  • 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-01T11:02:44+00:00Added an answer on June 1, 2026 at 11:02 am

    Something like this should work:

    $newarray = array();
    
    foreach ($array as $elements) {
       if (empty($newarray[$elements['dateTime'])) {
         $newarray[$elements['dateTime']] = $elements['offerIDs'];
       } else {
         $newarray[$elements['dateTime']] .= $elements['offerIDs'];
       }
    }
    

    Now run a simple sort by time using the code provided by mingos.

    The re-arrange the array:

    $finalarray = array();
    
    foreach ($array as $d => $v) {
        $finalarray[] = array('dateTime' = $d, 'offerIDs' => $v);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application used by pretty tech-savey people and they want small island
I have a listbox with values. Now I need to sort that listbox, BUT
I was listening to a tech talk and the speaker mentioned that they used
Quick backstory...I have some training in database design and administration. I have used them
I'm currently running PHP 5.3.9, Apache 2.2.22, Mandriva 2010.2. We used to be running
How to make red banner ad shown in the top of : http://forum.creditcardpaymentgateways.in/index.php same
making an Access database (2003) that is mainly used by other programmers and tech
I have used JD decompiler for decompiling a jar file. Affter do that I
If you have used indeed.com before, you may know that for the keywords you
Does Apple or anyone have a glossary of terms used in iphone and android

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.