Wednesday, 15 February 2012

php - Using in_array with currency symbol? -


I am working on a PHP file which is a value (given by an array from another website) currency (ex. To say in â €?)

I thought of using the in_array function to check whether the price returned from other webpages is currency or not . Only problem: it does not recognize that symbol, even if I use the predefined array if I try to change the $ currency array in the actual value given by the price currency, it will work. Thanks in advance! $ html = file_get_contents ('http: // thewebsite'); Preg_match_all ("thepriceclass", $ html, $ a); Forex Currency ($ $ Key = & gt; $ value as End ($ A)) {print print_r ($ value, true) '& Lt; Br> & # 39; & # 39; $ Currency = array ("â ?? ​​¬"); $ Value = str_split ($ value); $ Message = "this listing = / = â ?? ¬"; Forex currency ($ letter as $ letter) {if (in_array ($ letter, $ currency)) {$ message = "this list == â ?? ¬"; break; }} $ Message echo; break; }

How many currencies do you have? This is not for all of them, but why not use the iOS code (eg US Dollar, Euro, JPY, etc.)?

I will create a little function that converts symbols into code and vice versa.

Edit:

Did you say in the comment that you? Working with ¬, $, £, and PÑ ?? Ð ±.

I think the problem is encoding, either because PHP is Latin 1, or such things.

I only use the currency code (). In your case: Compare with US Dollar, Euro, GBP, RUB, and this.

I do not fully understand your code, as you look for the value of the array, but do you always print? ? ¬. I think this is just for testing.

I do:

  $ currency = array ('EUR');   

or:

  $ currency = array ('USD', 'EUR', 'GBP', 'RUB');   

If you can not use the above then I want to do something like this ...

  $ currencies = array ('USD' = & Gt; '$', 'EUR' = & gt; 'â', 'GBP' => 'one £', 'RUB' = & gt; 'PAN ?? Ð ±');   

... and use array values ​​and keys to compare.

Will this work?

No comments:

Post a Comment