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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:04:37+00:00 2026-05-31T12:04:37+00:00

I have a multi-dimensional array: membership = array(5) { [0]=> array(4) { [0]=> string(21)

  • 0

I have a multi-dimensional array:

membership = array(5) { 
 [0]=> array(4) { [0]=> string(21) "Group A" [1]=> string(9) "10/1/2011" [2]=> string(9) "3/31/2012" [3]=> string(8) "00004130" } 
 [1]=> array(4) { [0]=> string(22) "Group B" [1]=> string(8) "4/1/2011" [2]=> string(9) "9/30/2011" [3]=> string(8) "00005005" } 
 [2]=> array(4) { [0]=> string(22) "Group A" [1]=> string(9) "10/1/2010" [2]=> string(9) "3/31/2011" [3]=> string(8) "00004130" } 
 [3]=> array(4) { [0]=> string(22) "Group B" [1]=> string(8) "4/1/2010" [2]=> string(9) "9/30/2010" [3]=> string(8) "00005005" }  
 [4]=> array(4) { [0]=> string(22) "Group B" [1]=> string(8) "10/1/2010" [2]=> string(9) "3/31/2011" [3]=> string(8) "00005005" }  
}

I need to discover which group is in the membership array and how many times it appears.

PHP’s count() does not have recursive capability, but it’s output would be ideal if it did (i.e. [‘Group A’] => 2 [‘Group B’] => 3 ).

I thought about using the array_diff_uassoc() but, I’m just not sure. So I thought it wise to ask for some help before I wander aimlessly down the wrong path. I am sure there is more than one way, but I always find very interesting coding concepts on SO.

I’m running php 5.3.5 Thank you in advance for your suggestions and help.

  • 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-31T12:04:38+00:00Added an answer on May 31, 2026 at 12:04 pm

    This should do the trick with minimal code:

    $memberships = array(); // Your multi-dimensional array
    
    foreach($memberships as $membership)
    {
       $count[$membership[0]]++;
    }
    
    var_dump($count)
    

    Sorry for the late post BTW, I wanted to test it and make sure it would work as expected.

    Output is:

    array(2) {
      ["Group A"]=>
      int(2)
      ["Group B"]=>
      int(3)
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a multi-dimensional array, which basically consists of one sub-array for each year.
i have an multi-dimensional array which looks like $a[] = array('id' => '1', 'city'
I have a multi-dimensional array which contains ten thousands of data. A lot... The
I have a multi-dimensional array such as: String[][] greatCities = new String[2][2]; greatCities[0][0] =
I have the following multi-dimensional array in Ruby: [[1,2], [3], [4,5,6]] I need to
I have a multi dimensional String array process[100][2] like following : Y B C
I have a PHP function which populates a multi-dimensional array $client->getResponse() I want to
I have a multi-dimensional array that I need to loop through and create <td></td>
I have a multi-dimensional array of databases, which was generated from my server: //
Okay, I have a multi-dimensional array which is statically-allocated. I'd very much like to

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.