regex - Return numeric value from an string in PHP -


How do I get numeric values ​​from the string? In my case string, R1350.00 and

expected output:

  1350  

I tried The following:

  $ result = preg_replace ("/ [^ a-zA-Z0- 9] + /", "", 'R1350.00');  

But I also want to remove the last two string 00 This is an amount value in ZAR and I have to store the integer values ​​in my database

And then

  $ str = 'R1350 .00'; $ Str = str_replace ('R', ''. $ Str); $ Str = number_format ($ str, 0, '', ''); Copy $ str; // Output 1350  

Comments