Skip to content
Advertisement

How to get custom characters from very large string in PHP

I have a string of currencies – currency code, name and rates (first rate is units per EUR and second is EUR per unit).

JavaScript

and so on… IMPORTANT – This is copy/paste string so whitespace count is like in example and it can be random between integers and words. String is in one line without line breaks.

So my goal here is to get currency code and currency rate “unit per EUR” (first value)

Preferable output associative array.

Example:

JavaScript

and so on for every currency.

I can’t use any API.

Can anyone help me with this task?

Update: Piece of original string with line breaks

JavaScript

Advertisement

Answer

I hope this is something that you need. Check it please

JavaScript

Just change list of currencies if you need something else like only usd and gbp will be USD|GBP and so on

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement