Validate a float with PHP

Free Scripts :: PHP :: Validation :: Validate a float with PHP

Author: Salman Javaid

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

Comments

No comments. Be the first one.

Leave a comment

Full Name*
Comments*
Security Code*

Our Partners

Getty Icons  Salman Creations
Free High Quality Images  Learn Free Languages 
Opal Hosting  R-Tech Solutions
  • Submit a Script

    Click here to submit your script.