Q:

Counting duplicate values in a multidimensional array and populating values based on that

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?

A:

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.

