$rootbeer = (float) $InvoicedUnits;

Should do it for you. Check out Type-Juggling. You should also read String conversion to Numbers.

Answer from Sampson on Stack Overflow
🌐
PHP
php.net › manual › en › function.floatval.php
PHP: floatval - Manual
For the sake of comparing and to make myself clear I use the name parseFloat in stead of getFloat for the new function: <?php function parseFloat($ptString) { if (strlen($ptString) == 0) { return false; } $pString = str_replace(" ", "", $ptString); if (substr_count($pString, ",") > 1) $pString = str_replace(",", "", $pString); if (substr_count($pString, ".") > 1) $pString = str_replace(".", "", $pString); $pregResult = array(); $commaset = strpos($pString,','); if ($commaset === false) {$commaset = -1;} $pointset = strpos($pString,'.'); if ($pointset === false) {$pointset = -1;} $pregResultA =
🌐
W3Schools
w3schools.com › php › func_var_floatval.asp
PHP floatval() Function
Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, Python, PHP, Bootstrap, Java, XML and more.
🌐
GeeksforGeeks
geeksforgeeks.org › php › how-to-convert-string-to-float-in-php
How to convert String to Float in PHP ? - GeeksforGeeks
July 23, 2025 - The floatval() function in PHP converts a string to a floating-point number. It extracts the numeric value from the string, ignoring non-numeric characters.
🌐
Plus2Net
plus2net.com › javascript_tutorial › math-parseFloat.php
parseFloat function to convert string to floating pont number in JavaScript
parseFloat(input_string); By using parseFloat function we can convert strings to float numbers. To convert string to integer we can use parseInt function.
🌐
W3Schools
w3schools.com › jsref › jsref_parsefloat.asp
JavaScript parseFloat() Method
The parseFloat() method parses a value as a string and returns the first number.
🌐
Easymorph
help.easymorph.com › doku.php
ParseFloat(text) [EasyMorph Help]
ParseFloat(text) syntax:functions:parsefloat · ParseFloat(text) Description · Arguments · Remarks · Examples · See also · Category: Text function · This function parses a number in scientific notation (as a text value) into a decimal number. Return value type: Number ·
🌐
Locutus
locutus.io › php › var › floatval
PHP's floatval in JavaScript | Locutus
February 2, 2026 - The native parseFloat() method of JavaScript returns NaN when it encounters a string before an int or float value. Here's what our current JavaScript equivalent to PHP's floatval looks like.
🌐
Reddit
reddit.com › r/learnprogramming › php: can´t convert string to float
r/learnprogramming on Reddit: PHP: Can´t convert string to float
November 25, 2021 -

EDIT: SOLVED.

Simplified example:

$A = "41"; 
$B = floatval($A);

B returns 0. Was kind of expecting 41, but it doesnt. What am i doing wrong?$A gets data from a function, but when i echo it out, it writes 41. Adding floatval, changes it to 0.

Real code:

/*TEsting output*/
echo "Supprice:" . $suppPrice;   
echo "<br />Floatvalg supprice: ". floatval($suppPrice);

**Output:**Supprice:41Floatvalg supprice: 0

EDIT: Adding info.

Find elsewhere
🌐
w3resource
w3resource.com › php › function-reference › floatval.php
PHP floatval() function - w3resource
?php $var_name1="122.00,50"; $var_name2="122.00"; $var_name3="122.50"; $var_name4="122,50"; $var_name5="122 50"; $var_name6="0.50"; $var_name7="0,50"; $var_name8="-122.50"; $var_name9="-122,50"; $var_name10="-122 50"; echo floatval($var_name1)."<br>"; echo floatval($var_name2)."<br>"; echo floatval($var_name3)."<br>"; echo floatval($var_name4)."<br>"; echo floatval($var_name5)."<br>"; echo floatval($var_name6)."<br>"; echo floatval($var_name7)."<br>"; echo floatval($var_name8)."<br>"; echo floatval($var_name9)."<br>"; echo floatval($var_name10)."<br>"; ?>
🌐
TutorialKart
tutorialkart.com › php › php-convert-string-to-float
PHP - Convert string to float
May 7, 2023 - PHP String to Float - To convert string to float in PHP, you can use Type Casting method or PHP built-in function floatval(). In this tutorial, we will go through each of these methods and learn how to convert contents of a string to a floating ...
🌐
Reintech
reintech.io › blog › mastering-phps-intval-and-floatval-functions
Mastering PHP's `intval()` and `floatval()` Functions for Type Conversion | Reintech media
April 14, 2023 - The floatval() function in PHP is a built-in function that converts a variable's value to a float (a floating-point number). It takes one parameter: the variable to be converted. Like intval(), it stops at the first non-numeric character and ...
🌐
Codewars
codewars.com › kata › 57a386117cb1f31890000039 › discuss
Discuss Parse float | Codewars
Write function `parseFloat` which takes an input and returns a number or `Nothing` if conversion is not possible. Write function `parse_float` which takes a string/list and returns a number or '...
🌐
GitHub
gist.github.com › 7850853
Convert string value with commas into a float · GitHub
String to Float.php · This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters ·
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › parseFloat
parseFloat() - JavaScript | MDN
The parseFloat function converts its first argument to a string, parses that string as a decimal number literal, then returns a number or NaN.