you can also use typecasting instead of functions:
(float) $value;
![]() | floatval描述float floatval ( mixed var )返回变量 var 的 float 数值。 var 可以是任何标量类型。你不能将 floatval() 用于数组或对象。 ![]()
19-Apr-2005 08:30
you can also use typecasting instead of functions:
pillepop2003 at yahoo dot de
14-Dec-2004 06:38
Use this snippet to extract any float out of a string. You can choose how a single dot is treated with the (bool) 'single_dot_as_decimal' directive.
anonymous at start dot be
16-Jun-2004 10:00
Easier-to-grasp-function for the ',' problem.
thorcharAThotmailDOTcom
12-Mar-2004 04:40
Please note that conversion is not always correct, if you use a , instead of a . conversion wil return an integer on most servers.
vickers at hotpop dot com
27-Jan-2004 07:45
floatval() does not work with "$35,234.43", as it could not handle the '$' and the ','. The following takes care of all values, such that only numeric and the decimal sign are input into floatval(). (It probably shows I'm an old 'c' guy)...this function only lightly tested.
Zipi
25-Apr-2003 05:51
This function converts a string to a float no matter is the decimal separator dot (.) or comma (,). It also converts integers correctly. It takes the digits from the beginning of the string and ignores all other characters.
jason at shadonet dot com
08-Mar-2003 11:07
Instead of using floatval which only appeared in PHP 4.2 you could juse use $variable = (float)$variable | ![]() |