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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:43:29+00:00 2026-05-27T05:43:29+00:00

As you can see from the following array, there are three elements that appear

  • 0

As you can see from the following array, there are three elements that appear on Nov 18, and another two elements that appear on Nov 22. Can someone tell me how I can retrieve the counts of 3 and 2 respectively from this array? Basically, I want to end up with a result something like this:

Nov 18, 2011 = 3 items

Nov 22, 2011 = 2 items

Of course, the dates and the number of different dates will vary every time. Here is the array:

[
    [
        ['2011-11-18 00:00:00' => 'C'],
        ['2011-11-18 00:00:00' => 'I'],
        ['2011-11-18 00:00:00' => 'S']
    ],
    [
        ['2011-11-22 00:00:00' => 'C'],
        ['2011-11-22 00:00:00' => 'S']
    ]
]
  • 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-27T05:43:30+00:00Added an answer on May 27, 2026 at 5:43 am

    Does this work for what you need?

    $dates = array(array(array("2011-11-18 00:00:00" => C), array("2011-11-18 00:00:00" => I),array
    ("2011-11-18 00:00:00" => S)),
    array(array("2011-11-22 00:00:00" => C), array("2011-11-22 00:00:00" => S)));
    
    $date_count = array();  // create an empty array
    
    foreach($dates as $date) {  // go thought the first level
        foreach($date as $d) {  // go through the second level
            $key = array_keys($d);  // get our date
            // here we increment the value at this date
            // php will see it as 0 if it has not yet been initialized
            $date_count[$key[0]]++;
        }
    }
        // show what we have
    print_r($date_count);
    

    Prints:

    Array ( [2011-11-18 00:00:00] => 3 [2011-11-22 00:00:00] => 2 )
    

    Note: this assumes that you will always be getting data as you structured your array and that each date will be formatted the same. If you can’t assume each date will be formatted, this would be a simple conversion using the date() function. If you can’t assume that you will get data structured exactly like this, the best way to tackle that would probably be through a recursive function.

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

Sidebar

Related Questions

I had a following interview question. There is an array of nxn elements. The
I have some really funky code. As you can see from the code below
As you can see this is a question from a non web developer. I
How can I create a Popup balloon like you would see from Windows Messenger
How can I remove the animation from this jQuery modal window? You can see
While HTML Scraping is pretty well-documented from what I can see, and I understand
From a security perspective, I can see simply doing an 'eval' on incoming JSON
From http://developer.yahoo.com/yui/docs/YAHOO.util.DataSourceBase.html#method_sendRequest , you can see the oCallback is an object literal with the
I'm making this method retrieve records from the Data Base. As you can see
Say a table has several subclass types. How can I see all columns from

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.