The solution is already in pear : http://pear.php.net/package/Math_RPN
I suspect you could address security concerns by limiting the input to
valid characters in your arithmetic needs:
if (preg_match('|^[0-9.+/*-]+$|', $expression)){
eval("$foo = $expression");
return $foo;
}
On Fri, December 7, 2007 8:51 am, Nathan Rixham wrote:
> In-Built PHP Functions for par
I've thought about this for the remainder of the day, and I can't see
any good reason why this functionality should not be implemented into
the core; it's basic fucntionality, a safe way of doing things and
couldn't take more than a day or two to add in from a single developer,
and surely it'd
Antony Dovgal wrote:
On 07.12.2007 18:05, Alexey Zakhlestin wrote:
I doubt this is needed in core, but sounds "ok" for an extension.
Yes, I'm sure a simple extension using re2c to parse the expressions
would be gladly accepted into PECL.
or something libeval based ...
http://members.bellat
On 12/7/07, Mike <[EMAIL PROTECTED]> wrote:
> Yes, an easy way to handle this functionality that is safe to use with
> user input would be REALLY nice.
>
> Specifically for allowing users to specify custom formulas to do all
> sorts of nifty stuff. Especially in reporting and payroll/commission
> a
Yes, an easy way to handle this functionality that is safe to use with
user input would be REALLY nice.
Specifically for allowing users to specify custom formulas to do all
sorts of nifty stuff. Especially in reporting and payroll/commission
applications.
We're currently working on a reporting
Daniel and Derick, thanks for the replies..
Daniel first.. is great :) however
$arithmetic_string = "3*5";
$arithmetic_value = arith($arithmetic_string);
not possible with the method you mentioned.
eval() yes this works, however personally I feel a simple arith() (or
more suitably named functi
On Fri, 2007-12-07 at 16:44 +0100, Derick Rethans wrote:
> On Fri, 7 Dec 2007, Nathan Rixham wrote:
>
> > In-Built PHP Functions for parsing of basic arithmetic and if possible
> > fraction to decimal and decimal to fraction
> >
> > $arithmetic_string = "3*5";
> > echo arith($arithmetic_string);
On Fri, 7 Dec 2007, Nathan Rixham wrote:
> In-Built PHP Functions for parsing of basic arithmetic and if possible
> fraction to decimal and decimal to fraction
>
> $arithmetic_string = "3*5";
> echo arith($arithmetic_string); // returns float 15
What's wrong with eval?
http://derickrethans.nl |
On Dec 7, 2007 9:51 AM, Nathan Rixham <[EMAIL PROTECTED]> wrote:
> In-Built PHP Functions for parsing of basic arithmetic and if possible
> fraction to decimal and decimal to fraction
PHP already handles half of what you're looking for by default.
> $arithmetic_string = "3*5";
> echo arith($a
Agreed, PECL or PEAR, some provision should be made, it's worth the
extra few bytes of code.
Thanks for the opinions
Nathan
Antony Dovgal wrote:
On 07.12.2007 18:05, Alexey Zakhlestin wrote:
I doubt this is needed in core, but sounds "ok" for an extension.
Yes, I'm sure a simple extension
On 07.12.2007 18:05, Alexey Zakhlestin wrote:
> I doubt this is needed in core, but sounds "ok" for an extension.
Yes, I'm sure a simple extension using re2c to parse the expressions
would be gladly accepted into PECL.
I don't see any need for this in the core, though.
> Also, I believe, quite a
I doubt this is needed in core, but sounds "ok" for an extension.
Also, I believe, quite a decent version of this can be written in php
(think PEAR)
On 12/7/07, Nathan Rixham <[EMAIL PROTECTED]> wrote:
> In-Built PHP Functions for parsing of basic arithmetic and if possible
> fraction to decimal a
13 matches
Mail list logo