Background:
I have created a website that displays exchange rates from different countries. I use the Google Currency Converter API to do the calculations.
http://www.google.com/ig/calculator?h1=en&q=9999gbp=?usd
Pay attention to the request that I submitted, for example. 9999 Great British Pounds
to United States Dollars
.
The API returns:
{lhs: "9999 British pounds",rhs: "15 769.4229 US dollars",error: "",icc: true}
Google separated 15 769.4229
with a space between 5
and 7
.
This causes a problem when I return the calculation results on my site, when the char space is replaced by a character ..
See screenshot below:
Any ideas what this symbol is called, can I try to remove it?
<?php // Check to ensure that form has been submitted if (isset($_POST['amount'], $_POST['from'], $_POST['to'])) { $amount = trim($_POST['amount']); $from = $_POST['from']; $to = $_POST['to']; try { $conversion = currency_convert($googleCurrencyApi, $amount, $from, $to); } catch (Exception $e) { echo 'Caught exception: ', $e->getMessage(); } // Check URL has been formed if ($conversion == false) { echo 'Sorry, something went wrong'; } else { echo $conversion[0], ' = ', $conversion[1]; } } function currency_convert($googleCurrencyApi, $amount, $from, $to) { $result = file_get_contents($googleCurrencyApi . $amount . $from . '=?' . $to); $expl = explode('"', $result); if ($expl[1] == '' || $expl[3] == '') { throw new Exception('An error has occured. Unable to get file contents'); } else { return array( $expl[1], $expl[3] ); } } ?>
Here is my code at the moment, so you understand my logic.