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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T16:39:28+00:00 2026-06-08T16:39:28+00:00

I have the following array, which is a load of arrays nested in a

  • 0

I have the following array, which is a load of arrays nested in a bigger array:

Array
(
    [0] => Array
        (
            [vote_for] => 15
        )

    [1] => Array
        (
            [vote_for] => 15
        )

    [2] => Array
        (
            [vote_for] => 15
        )

    [3] => Array
        (
            [vote_for] => 5
        )

    [4] => Array
        (
            [vote_for] => 5
        )

    [5] => Array
        (
            [vote_for] => 2
        )

    [6] => Array
        (
            [vote_for] => 2
        )

    [7] => Array
        (
            [vote_for] => 2
        )

    [8] => Array
        (
            [vote_for] => 2
        )

    [9] => Array
        (
            [vote_for] => 2
        )

    [10] => Array
        (
            [vote_for] => 2
        )

    [11] => Array
        (
            [vote_for] => 2
        )

    [12] => Array
        (
            [vote_for] => 2
        )

    [13] => Array
        (
            [vote_for] => 2
        )

    [14] => Array
        (
            [vote_for] => 2
        )

)

I want to do the equivalent of array_count_values on this array, such that I get 15 => 3, 5 => 2 and 2 => 10. How do I un-nest the arrays to 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-06-08T16:39:30+00:00Added an answer on June 8, 2026 at 4:39 pm

    You may want to try reforming your array to count:

    $count_array = array();
    foreach ($arr as $v) {
       $count_array[] = $v['vote_for'];
    }
    
    // Now get the counts
    $the_count = array_count_values($count_array);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following method, which basically calls a request to load an array
All, I have the following array and function, which will create a multidimensional array
I have a byte array which needs to be marshalled into the following struct:
I have an array called: $fragment = array($fragment); Which has the following three values:
I have the following script currently, which gets the category IDs as arrays: $sql_select_categories
I have following array, that I need to operate by hand on bitmaps. const
I have the following code which uses an array to write the result to
I have a foreach syntax which generates following outcome: array 0 => array 'value'
I have the following code: <?php $this->beginWidget('zii.widgets.jui.CJuiDialog', array( 'id'=>'mydialog', // additional javascript options for
I have a Swings GUI which contains a JComboBox and I want to load

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.