$num = "-*1,000";

// Remove all illegal characters from num 
$num = filter_var($num , FILTER_SANITIZE_NUMBER_INT);
//FILTER_SANITIZE_NUMBER_INT
// Validate num 
if (filter_var($num , FILTER_SANITIZE_NUMBER_INT)) {
echo("$num is a valid INT");
} else {
echo("$num is not a valid INT");
}

반응형

+ Recent posts