【发布时间】:2017-04-17 21:45:07
【问题描述】:
我建立了一个谷歌货币转换器,但我不明白这部分代码
$converted_amount = preg_replace("/[^0-9\.]/", null, $get[0]);
这个模式的作用是什么,这里的null是什么意思?
完整代码:
$amount = urlencode($_POST['amount']);
$from_Currency = urlencode($_POST['from']);
$to_Currency = urlencode($_POST['to']);
$get = file_get_contents("https://www.google.com/finance/converter?a=$amount&from=$from_Currency&to=$to_Currency");
$get = explode("<span class=bld>",$get);
$get = explode("</span>",$get[1]);
print_r($get);
$converted_amount = preg_replace("/[^0-9\.]/", null, $get[0]);
【问题讨论】:
-
你可以在这里找到
preg_replace的解释:php.net/manual/en/function.preg-replace.php