阵列工作([0] =>数组([0] => 21.2694 USD)[1] =>数组([0] => 21.2694 USD))SUBSTR不是在阵列
(这是basicall谷歌货币转换器)
echo $ arr [0] [0]; //输出是21.2694 USD
但我想输出像21.26 USD
什么是尝试是, 回波SUBSTR($ ARR [0] [0],0,5); //对于这个SUBSTR线我预计产量21.26
,但我想起来了空白页,
如果我犯的错误
我想21.26USD作为输出,如果我给输入为21.2694美元
基本上是做货币转换器(谷歌API)
但API产生的结果与本29.5645美元,我想打出来把为29.56美元,
这是我的片段,
$from_currency = "GBP"; $selected_currency = 'USD'; $txt_cash_price = '10'; $txt_card_price = '14'; $get_currency = file_get_contents("http://www.google.com/finance/converter?a=$txt_cash_price&from=$from_currency&to=$selected_currency"); preg_match_all("/(.*)/", $get_currency, $matches,PREG_PATTERN_ORDER); $caprice = $matches[0][0]; OUPUT SOMTHING LIKE THIS 15.2070 USD
但我想输出15.20美元
使用'error_reporting'和'display_e启用错误报告rrors'。 – Sjoerd 2010-07-02 08:36:07
产量是不是21.27 USD? – 2010-07-02 08:58:07
你想要截断或舍入结果吗? – Toto 2010-07-02 09:04:02