Array ( [0] => Array ( [0] => 21.2694 USD ) [1] => Array ( [0] => 21.2694 USD ) )
(this is basicall google currency converter)
echo $arr[0][0]; //output is 21.2694 usd
But i want Output like 21.26 USD
What is tried is ,
echo substr($arr[0][0],0,5);//For this substr line i expected output is 21.26
But am getting just blank page,
Where i made mistake
i want 21.26USD as the output if i give the input as 21.2694 USD
Basically am doing the currency converter (google api)
But api producing result as 29.5645 USD from in this , i want to make out put as 29.56 USD ,
This is my snippet ,
$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
But i want output as 15.20 USD
You can use round