public function getCategoriesRelated($i = null)
    {
        $wiki_api = $this->base_api . 'action=query&prop=categories&pageids=' . $this->getId();
        $json_wapi = json_decode(file_get_contents($wiki_api), true);

        $result = $this->get_list_or_item($json_wapi['query']['pages'], 'categories', false, []);
        $categories = [];

        foreach ($result as $page_id => $items) {
            $categories[$page_id] = [];
            foreach ($items as $item) {
                $categories[$page_id][] = ltrim(strstr($item['title'], ':'), ':');
            }
        }

        return ($i === null) ? $categories : $categories[$this->article_ids[$i]];
    }
public function getCategoriesRelated($i = null)
    {
        $wiki_api = $this->base_api . 'action=query&prop=categories&pageids=' . $this->getId();
        $json_wapi = json_decode(file_get_contents($wiki_api), true);

        $result = $this->get_list_or_item($json_wapi['query']['pages'], 'categories', false, []);
        $categories = [];

        foreach ($result as $page_id => $items) {
            $categories[$page_id] = [];
            foreach ($items as $item) {
                $categories[$page_id][] = ltrim(strstr($item['title'], ':'), ':');
            }
        }

        return ($i === null) ? $categories : $categories[$this->article_ids[$i]];
    }
public function getCategoriesRelated ( $ i = null ) { $ wiki_api = $ this -> base_api . 'action=query&prop=categories&pageids=' . $ this -> getId ( ) ; $ json_wapi = json_decode ( file_get_contents ( $ wiki_api ) , true ) ; $ result = $ this -> get_list_or_item ( $ json_wapi [ 'query' ] [ 'pages' ] , 'categories' , false , [ ] ) ; $ categories = [ ] ; foreach ( $ result as $ page_id => $ items ) { $ categories [ $ page_id ] = [ ] ; foreach ( $ items as $ item ) { $ categories [ $ page_id ] [ ] = ltrim ( strstr ( $ item [ 'title' ] , ':' ) , ':' ) ; } } return ( $ i === null ) ? $ categories : $ categories [ $ this -> article_ids [ $ i ] ] ; }
Get related categories for the articles
@param  integer $i
@return array
Get related categories for the articles