Reputation:
$url = 'the web address I want to get the first and second numbers close to $' ;
$str = file_get_contents($url);
preg_match_all('/ ([$]) *(\d+(:?.\d+)?)/', $str, $matches, PREG_SET_ORDER);
$i=0;
foreach ($matches as $val) {
if($i==0) $first=$val[2] ;
if($i==3) $second=$val[2] ;
$i++;
}
$bad_symbols = array(",", "."); $first = str_replace($bad_symbols, "", $first);
$bad_symbols = array(",", "."); $second = str_replace($bad_symbols, "", $second);
echo $first . "</br>";
echo $second;
it worked fine till yesterday what could be the problem?
Upvotes: 0
Views: 263
Reputation: 401022
I see at least two possible explanations :
preg_match_all
file_get_contents
; if it's false, it might be the cause of the problemallow_url_fopen
directiveIf you activate error_reporting
(see also), you might also get some informations that could prove usefull...
Upvotes: 3
Reputation: 5478
Maybe system administrator has changed allow_url_fopen directive, that means you can't access files that are not on your server. Check what file_get_contents() returns, because you gave us very little information about error.
Another problem, as mentioned above, could be that remote site has been changed :)
Upvotes: 0