php string to float 2 decimal code example
Example 1: php float 2 decimais
$foo = "105";
echo number_format((float)$foo, 2, '.', '');
Example 2: 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);
?>