Code: Select all
if(eregi("^(rm){1,1}(\ )?[0-9]+(\.)?[0-9]*[m|k]?$",$str)){
$temp = $str;
$tpower = 1;
$temp = str_replace("rm","",$temp);
$temp = str_replace(" ","",$temp);
if(substr($temp,strlen($temp)-1) == "k") $tpower = 1000;
if(substr($temp,strlen($temp)-1) == "m") $tpower = 1000000;
$temp = str_replace("m","",$temp);
$temp = str_replace("k","",$temp);
echo "<br> temp ".$temp;
echo "<br> tpower ".$tpower;
$temp = $temp * $tpower;
echo "<br> total ".$temp;
}For example i have a string like "bla bla bla bla rm 1.2m bla bla bla" which i want to convert it to "bla bla bla rm1200000 bla bla bla"
thanks in advance for any reply.