protected function GetMaxKey() { if (!$this->force_assoc && is_numeric($this->GetKey(0))) { return max(array_keys($this->values[0])); } // if associative, return the index of the last key return $this->GetHorizontalCount() - 1; }