parse float in php code example
Example 1: convert a value to a float in php
$stringVal = "12.06";
$stringConvertedToFloat = floatval( $stringVal );
Example 2: string to float php
$floatValue = floatval("1.0");
Example 3: php float value
floatval ($var)
Example 4: Convert String to Float in PHP
phpCopy<?php
$mystring = "0.5674";
echo("This float number is of string data type ");
echo($mystring);
echo("\n");
$myfloat = floatval($mystring);
echo("Now, this float number is of float data type ");
echo($myfloat);
?>
Example 5: Convert String to Float in PHP
phpCopy<?php
$mystring = "0.5674";
echo("This float number is of string data type ");
echo($mystring);
echo("\n");
$myfloat = number_format($mystring, 4);
echo("Now, this float number is of float data type ");
echo($myfloat);
?>