Normalize number

From CodeCodex

PHP[edit]

<highlightsyntax> function normalizeNumber($number){ $s = ""; $a = array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9"); $is_dot = false; $number = trim($number); if($number != ""){ for($i = 0; $i < strlen($number); $i++){ $s.=in_array($number[$i], $a)?$number[$i]:""; if($number[$i] == "." && ($is_dot == false)){ $s.="."; $is_dot = true; } } } else{ $s = 0; } return $s; } </pre>