PHP Tutorial - PHP floatval() function






Gets the float value of var.

Syntax

PHP floatval() function has the following syntax.

float floatval ( mixed $var )

Parameter

  • var - scalar type to convert.

Return

The float value of the given variable. Empty arrays return 0, non-empty arrays return 1.

Example

Get the float value


<?php
$var = '122.34343The';
$float_value_of_var = floatval($var);
echo $float_value_of_var; // 122.34343
?>

The code above generates the following result.