I am currently working with an API where instead of floats or integers for currency I receive strings like these.
- $2.49
- £2.49
- €2.49
- etc.
The issue with that is that I need to store the value and currency separately but the currency needs to be stored as ISO Code, so for example EUR, USD or GBP instead of € and $.
Is there any way in PHP to get the currency code based on a currency symbol using the NumberFormatter or something like that?
Currently I just have a very long list of currency symbols and names which I use to do things like string_contains('$2.49', '$')
to check for a certain currency.