Validate a float with PHP
Free Scripts :: PHP :: Validation :: Validate a float with PHP
Author: Salman Javaid
Website: http://www.salman.be
Website: http://www.salman.be
- Validate a float value with php.
- How to validate a float with php.
- Validate a float value with php.
Function accepts a parameter and returns false if value is not a float.
Function
function isValidFloat($string){
if(!preg_match("/^[0-9]+(.[0-9]+)?$/",$string)){
return false;
}
}
Calling The Function
$string=5.25;
if(isValidInteger($string)!==false){
echo 'Value is a float';
}else{
echo 'Value is not a float';
}
Output
Value is a float




