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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:33:13+00:00 2026-06-03T13:33:13+00:00

I am pulling out a number of notes associated with a time from my

  • 0

I am pulling out a number of notes associated with a time from my database.

I’m not too hot with multidimensional arrays, but I’d like to group all the events together under the time that they occurred.

Here is one of my queries:

SELECT TIME(date) AS time, followupNote, completed, entityRef
FROM entity_followups
WHERE userRef = ?
AND DAY(date) = ?
AND MONTH(date) = ?
AND YEAR(date) = ?

An example output from this could be three rows, the first column being the time, then the note, completed, then the entityRef.

I want any rows with the same time to be grouped together in the array, e.g.

Array (
    [0] => Array (
        [0] => 12:00:00
        [1] => Array (
            [0] => note
            [1] => completed
            [2] => entityRef
        )
        [2] => Array (
            [0] => note2
            [1] => completed2
            [2] => entityRef2
        )
    )
)

But later on there will be other queries that collect other kinds of events which need to be added into the top level array, and if an event has the same time as one in the subarray, it needs to be added into 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-06-03T13:33:15+00:00Added an answer on June 3, 2026 at 1:33 pm

    I’ll assume that your existing code is enough for getting the time and value. Thus you will have these items in whatever variable or data structure you choose to use. For the purposes of this answer, I will assume these values already exist in the individual variables: $time, $value[0], $value[1], and $value[2]. Further, I will assume that the results are being loaded into the array $timesAndValues[]

    I think the key is to have the $timesAndValues[] array indexed on the corresponding time:

    if (isset($timesAndValues[$time]))
    { //The corresponding sub-array already exists, so we just need to load it
    
      //Push the array of values into the sub-array 
      array_push($timesAndValues[$time], $value);
    }
    else
    { //The corresponding sub-array does not exist yet, so we need to create it and load it
    
      //Create the sub-array
      $timesAndValues[$time] = array($time);
    
      //Push the array of values into the sub-array
      array_push($timesAndValues[$time], $value);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm pulling my hair out on this problem. I would like to show a
I can't figure this out. I have a query pulling data from a couple
How would one go about pulling out just a number in the text of
I am pulling data out of an old-school ActiveX in the form of arrays
I have data in Excel files that I am pulling out using the MS
I have a call back url, that i'm am pulling out the Lat and
Using JavaScript I am pulling names out of webpage and stringing them together somehow
Clojures clojure.xml/parse, clojure.zip/xml-zip and clojure.contrib.zip-filter.xml/xml-> are excellent tools for pulling values out of xml,
Pulling my hair out over this one. I have one wordpress install at /2009
Pulling my hair out. I've got a table 'Belts' with columns 'BeltID' and 'BeltColor'.

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.