PHP 8.5.0 Alpha 1 available for testing

Voting

: five minus three?
(Example: nine)

The Note You're Voting On

Frank
14 years ago
If someone is from a country that accepts decimal numbers in format 9.00 and 9,00 (point or comma), number validation would be like that:
<?php
$number_check
= "9,99";
if (
preg_match( '/^[\-+]?[0-9]*\.*\,?[0-9]+$/', $number_check)) {
return
TRUE;
}
?>

However, if the number will be written in the database, most probably this comma needs to be replaced with a dot.
This can be done with use of str_replace, i.e :
<?php
$number_database
= str_replace("," , "." , $number_check);
?>

<< Back to user notes page

To Top