Получение таблицы курсов валют на указанную дату

  • Автор темы phpMaster
  • Дата начала
P
phpMaster
Пример вызова функции для получения курсов на 4 ноября 2008:echo '<table border="1">'.getCur('04','11','2008').'</table>
Код:
echo '<table border="1">'.getCur('04','11','2008').'</table>';

function getCur($day,$month,$year){
    $tmp = file_get_contents("http://www.cbr.ru/currency_Base/daily.aspx?C_month=$month&C_year=$year&date_req=$day%2F$month%2F$year");
    return GetText('<table border="0" cellpadding="2" cellspacing="1" width="100%">','</table>',$tmp);
}
# Получение части текста
function GetText($findfirst,$findsecond,$text){
   if(strlen($findfirst)==0 || strlen($text)==0) return '';
   $i1 = strpos(' '.$text,$findfirst);
   if( $i1 == 0 ) return '';
   $text1 = substr($text,$i1+strlen($findfirst)-1);
   $i = strpos(' '.$text1,$findsecond);
   if( $i == 0 || strlen($findsecond)==0) return $text1;
   $text1 = substr($text1,0,$i-1);
   $text  = substr($text,$i1+$i+strlen($findsecond)+strlen($findfirst)-2);
   return $text1;
}
 
Сверху