public function groupData($data, $length) {
    $flipped = array();
    $e = 0;
    $j = 0;
    $old_value = NULL;

    foreach ($data as $datum => $value) {
      $j++;
      if ($j <= $length) {
        // If the value has changed and we are not just starting
        if (($value != $old_value)) {
          $e++;
          $flipped[$e][$value][$datum] = $datum;
          $old_value = $value;
        }
        else {
          $flipped[$e][$value][$datum] = $datum;
        }
      }
    }
  }
public function groupData($data, $length) {
    $flipped = array();
    $e = 0;
    $j = 0;
    $old_value = NULL;

    foreach ($data as $datum => $value) {
      $j++;
      if ($j <= $length) {
        // If the value has changed and we are not just starting
        if (($value != $old_value)) {
          $e++;
          $flipped[$e][$value][$datum] = $datum;
          $old_value = $value;
        }
        else {
          $flipped[$e][$value][$datum] = $datum;
        }
      }
    }
  }
public function groupData ( $ data , $ length ) { $ flipped = array ( ) ; $ e = 0 ; $ j = 0 ; $ old_value = NULL ; foreach ( $ data as $ datum => $ value ) { $ j ++ ; if ( $ j <= $ length ) { // If the value has changed and we are not just starting if ( ( $ value != $ old_value ) ) { $ e ++ ; $ flipped [ $ e ] [ $ value ] [ $ datum ] = $ datum ; $ old_value = $ value ; } else { $ flipped [ $ e ] [ $ value ] [ $ datum ] = $ datum ; } } } }
A simple utility function that given an array of datum=>value will group results based on
those that have the same value. Useful for grouping events based on state.

@param $data
@param $length
A simple utility function that given an array of datum = > value will group results based on those that have the same value . Useful for grouping events based on state .