text, $matches, PREG_SET_ORDER); if($matches) { foreach ($matches as $match) { preg_match('/\s+[A-Za-z0-9_]+\s*/', $match[0], $id_matches); $number = $this->getNumber($this->params->get('stats_api_url'), trim($id_matches[0])); $article->text = str_replace($match[0], $number, $article->text); } } return true; } public function getNumber($api_url, $id) { $url = $api_url . 'numbers/' . strtolower($id); $response = json_decode(file_get_contents($url)); if($response->code == 200) { return $response->statistics; } return "?"; } } ?>