Parse currency from string

前端 未结 5 1548
无人及你
无人及你 2021-01-02 18:25

I want to parse a currency from a string in PHP, I\'ve had a look at number formatter but haven\'t got PHP 5.3 or the ability to add extensions.

The currency will on

5条回答
  •  情书的邮戳
    2021-01-02 19:15

    (float)substr($input, strpos($input, "£")+1);
    

    This will get you the following results:

    float(0.9)
    float(100)
    float(100.1)
    float(1000)
    float(153.93)
    

    EDIT: updated to reflect the change to question. this is assuming all strings are like the one you gave as an example.

提交回复
热议问题