How can I get the numeric value from an string? In my case string is
I tried the following:
$result = preg_replace("/[^a-zA-Z0-9]+/", "", 'R1350.00');
but I also want to remove the last two string
00. It is an amount value in ZAR. and I have to store the integer value in my database.
You can use
str_replace function and then
$str = 'R1350.00'; $str = str_replace('R',''.$str); $str = number_format($str,0,'',''); echo $str; //output 1350