mCategories = $data; $this->format(); } public static function instance() { if(self::$stInstance == null) { self::$stInstance = new category(); } return self::$stInstance; } private function format() { $result = []; foreach ($this->mCategories as $key => $val) { $item['category_id'] = $key; $item['title'] = $val; $result[] = $item; } $this->mResult = $result; } public function categories() { return $this->mResult; } public function title($category_id) { if(array_key_exists($category_id,$this->mCategories)) { return $this->mCategories[$category_id]; } else { return ''; } } }