PHP Strings – Convert string to float

In this post we will be creating a PHP script that will convert a string to a float type. To do this we will be casting the string in to a numeric float type. See the snippet of code for how this is done.

$num = "32.3215";
$float = (float)$num;
echo $float;

Leave a Reply