Re: how to conver a string to float

From: Date: Sun, 08 Feb 2004 05:05:05 +0000
Subject: Re: how to conver a string to float
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-177123@lists.php.net to get a copy of this message
On Sat, 2004-02-07 at 23:50, Michal Migurski wrote: > Another possibility is to pipe the expression to bc, which could do the > input check for you, and probably covers a lot of syntactic ground. > Slightly less resource-efficient, but you don't have to reinvent the > wheel (untested, unix only): > $result = shell_exec("echo '${expr}' | bc"); Both eval and piping to bc via the shell work but open up big security holes if you are not careful. If you have bcmath or gmp enabled in php I recommend looking at these functions: http://www.php.net/manual/en/function.gmp-mul.php http://www.php.net/manual/en/function.bcmul.php -- Adam Bregenzer adam@bregenzer.net http://adam.bregenzer.net/

« previous php.general (#177123) next »