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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:05:58+00:00 2026-06-15T08:05:58+00:00

I have the following array: Array ( [0] => Array ( [event_id] => 90

  • 0

I have the following array:

Array
(
[0] => Array
    (
        [event_id] => 90
        [event_date] => 2012-11-29
        [multi] => 1
    )

[1] => Array
    (
        [event_id] => 86
        [event_date] => 2012-11-29
        [multi] => 1
    )

[2] => Array
    (
        [event_id] => 52
        [event_date] => 2012-11-30
        [multi] => 0
    )

)

which I am generating on the fly with the following code:

        $dates = array();
    $curr_date = array();
    $iteration_date = null;

    foreach ( $query as $q ) {
        $event_id = $q->ID;

        $curr_date['event_id'] = $event_id;
        $curr_date['event_date'] = date('Y-m-d', get_post_meta($event_id, 'event_unix_date', true));


        if ( empty($iteration_date) ) {
            $iteration_date = $curr_date['event_date'];
            $curr_date['multi'] = 1;
        } elseif ( $iteration_date == $curr_date['event_date'] ) {
            $curr_date['multi'] = 1;
        } else {
            $iteration_date = $curr_date['event_date'];
            $curr_date['multi'] = 0;
        }

        array_push($dates, $curr_date);
    }

This is based off a MySQL database result.

What I’m attempting to do is:
Check to see if there are arrays with the same [event_date], if so, count how many, do a special piece of code (a function is fine), and depending on what is output, set the [multi] value to 1, 2 or 3 depending on that condition.

Basic logic would be:

Check to see if there are multiple [event_date]‘s. If there are, check category on all of the matching duplicate dates. If all dates are X, populate [multi] with 1, if all dates are Y, populate with 2, if dates are mixed X & Y, populate with 3. If there is only a single date, populate with 1 or 2 depending on which category it is in.

I thought I was on the right track by just looping through the query (it is DESC by event_date), but this won’t let me check the individual entries category and populate based on that.

Can anyone point me in the right direction?

  • 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-15T08:05:59+00:00Added an answer on June 15, 2026 at 8:05 am

    Are we to assume a sorted multidimensional array (by ascending [event_date]) every time?
    If so, you could:

    function multi_counter($big_array, $sorted, $storage){
    $multi_count=0; // since by default there are no multiples
    $multi_items=array(0); // starting at the beginning of the array
    $length = count($big_array); // counting before loop
    for($i=0;$i<$length-1;$i++){ // the -1 is so we don't get undefined index on last run
        if($big_array[$i][$sorted]===$big_array[$i+1][$sorted]){ //testing for similarity
            $multi_items[]=$i+1;        // adding the multi found to temp storage
            $multi_count++;             // adding to # of multis
    // CALL A FUNCTION HERE SINCE THEY MATCH???
        }else{  
            foreach($multi_items as $key=>$multi){  // if not similar, go back and assign stored multis
                $big_array[$multi][$storage]=$multi_count;  // assigning stored vals
            }
            $multi_count=0; // resetting counter
            $multi_items=array($i+1); // resetting to next item
        }
    }
    foreach($multi_items as $key=>$multi){  // forcing assign at end of loop
        $big_array[$multi][$storage]=$multi_count; 
    }
    return $big_array; // returning the newly modified array
    

    }

    Is that what you were talking about? You can insert a call to another function where I commented one in. Question was unclear, but this is what it sounded like what you wanted.

    The function parses the array given as the first parameter, checking if the second parameter is similar in each subarray, and storing them in the subarrays in a key named whatever you put for the third parameter.

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

Sidebar

Related Questions

I have the following code, which is supposed to create a form on the
I have the following segment of code in which I want to Group everything
In my view file I current have the following code: @if ((Model.CustomerOrderTrackings != null)
I have the following code which pulls json data from an ASP.NET page and
I have the following array in fortran77 dec(3, 25000), even if only the 8898
I have following array, that I need to operate by hand on bitmaps. const
I have the following array: $franchise_a_status[] = array( 'id' => $franchise['franchise_id'], 'text' => $franchise['franchise_surname'].
I have the following array(in python): arr= ['\n', ' a#B\n', ' c#D\n'] Now I
I have taken following array; to fill-up gallery: private Integer[] mImageIds = { R.drawable.one,
I have the following array: Array ( [0] => BCD [1] => ACE [2]

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.