In Php, how to get float value from a mixed string?

前端 未结 7 584
一向
一向 2021-01-11 20:38

I got a string like:

$str = \"CASH55.35inMyPocket\";

I want to get 55.35 only.

I tried:

$str = flo         


        
7条回答
  •  失恋的感觉
    2021-01-11 21:25

    function extract_numbers($string)
    {
    preg_match_all('/([\d]+)/', $string, $match);
    return $match[0];
    }
    

提交回复
热议问题