The floatval() function is an inbuilt function in PHP which returns the float value of a variable.
Syntax:
php
php
float floatval ( $var )Parameters: This function accepts one parameter which is mandatory and described below:
- $var: The variable whose corresponding float value will be returned. This variable should not be an object.
Input : $var = '41.68127E3' Output : 41681.27 Input : $var = '47.129mln' Output : 47.129Below programs illustrate the use of floatval() function in PHP: Program 1:
<?php
$var = '41.68127E3';
$float_value = floatval($var);
echo $float_value;
?>
Output:
Program 2:
41681.27
<?php
$var = '47.129mln';
$float_value = floatval($var);
echo $float_value;
?>
Output:
Reference: https://www.php.net/manual/en/function.floatval.php47.129