note 82078 deleted from function.number-format by nlopess
| From: | nlopess@php.net | Date: | Sun, 30 Mar 2008 11:29:44 +0000 |
| Subject: | note 82078 deleted from function.number-format by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-137751@lists.php.net to get a copy of this message | ||
Note Submitter: ernesto_vargas at yahoo dot com
----
I took www.produkte24.com function mk_price_to_float to be able to eliminate any currency symbol or
positive/negative symbol.
function sanitize_amount($value){
$value = trim($value);
if(preg_match("~^([^0-9]*)+([0-9]+|(?:(?:[0-9]{1,3}([.,'Ù«
]))+[0-9]{3})+)(([.,·])[0-9]{1,2})?$~", $value, $r)){
if(!empty($r['3'])){
$pre = preg_replace("~[".$r['3']."]~", "",
$r['2']);
}else{
$pre = $r['2'];
}
if(!empty($r['5'])){
$post = ".".preg_replace("~[".$r['5']."]~",
"", $r['4']);
}else{
$post = false;
}
$value = $pre.$post;
return $value;
}
return false;
}