class exchange_rates { public function curl($url) { $ch = curl_init($url); curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt ($ch, CURLOPT_COOKIEJAR, dirname(__FILE__).'/cookie.txt'); curl_setopt ($ch, CURLOPT_COOKIEFILE, dirname(__FILE__).'/cookie.txt'); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 60); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_HEADER, 1); curl_setopt ($ch, CURLOPT_ENCODING, 'utf-8'); curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt ($ch, CURLOPT_HTTPHEADER, array( )); $result = curl_exec($ch); curl_close($ch); $this->result = $result; return $result; } public function parse_money($curl) { $pattern = "/(?:)(.*?)(?:<\/big>)/"; preg_match_all($pattern, $curl, $matches); return $matches; } } $rates = new exchange_rates(); $curl = $rates->curl('http://finance.i.ua/'); $matches = $rates->parse_money($curl); preg_match_all($pattern, $curl, $matches); echo 'Покупка: USD=' . $matches[1][0] . '; EU=' . $matches[1][3]; echo '; RUB=' . $matches[1][6] . "\n"; echo 'Продажа: USD=' . $matches[1][1] . '; EU=' . $matches[1][4]; echo '; RUB=' . $matches[1][7] . "\n";