php set_time_limit XMLrates file_get_contents http www cbr ru scripts

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
set_time_limit(1);
$XMLrates = file_get_contents('http://www.cbr.ru/scripts/XML_daily.asp?date_req='.date('d/m/Y'));
echo '--|<br />';
$codes = Array('USD', 'EUR');
echo '-2-|<br />';
$rates = Array();
preg_match_all('#<Name>(.*?)</Name>#', $XMLrates, $rates['title']);
preg_match_all('#<Nominal>(.*?)</Nominal>#', $XMLrates, $rates['quantity']);
preg_match_all('#<Value>(.*?)</Value>#', $XMLrates, $rates['rate']);
preg_match_all('#<CharCode>(.*?)</CharCode>#', $XMLrates, $rates['code']);
echo '3-33<br />';
echo '666<br />';
for ($i = 0; $i < 10; $i++) {
}
echo '3-33<br />';
echo dump(print_r($rates, 1));
die('18');
for ($i = 0; $i < count($rates['title'][1]); $i++) {
$rates[$i]['title'] = $rates['title'][1][$i];
$rates[$i]['quantity'] = $rates['quantity'][1][$i];
$rates[$i]['rate'] = $rates['rate'][1][$i];
$rates[$i]['code'] = $rates['code'][1][$i];
echo $i." - $rates[$i]['code']<br />";
}
echo '3-33<br />';
echo dump(print_r($rates, 1));
die('18');
foreach ($rates as $key => $value)
if (!in_array($value['code'], $codes))
unset($rates[$key]);
echo dump(print_r($rates, 1));
//echo $XMLrates;
?>