Re: [PHP-DEV] Thoughts on Feature Request - Arithmetic

2007-12-08 Thread Lokrain
The solution is already in pear : http://pear.php.net/package/Math_RPN

Re: [PHP-DEV] Thoughts on Feature Request - Arithmetic

2007-12-07 Thread Alexey Zakhlestin
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 and

[PHP-DEV] Thoughts on Feature Request - Arithmetic

2007-12-07 Thread Nathan Rixham
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 $arithmetic_string = 1/2; echo arith($arithmetic_string); // returns float 0.5 $fraction_string =

Re: [PHP-DEV] Thoughts on Feature Request - Arithmetic

2007-12-07 Thread Nathan Rixham
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

Re: [PHP-DEV] Thoughts on Feature Request - Arithmetic

2007-12-07 Thread Derick Rethans
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? ?php eval( '$res = 3 * 5;' );

Re: [PHP-DEV] Thoughts on Feature Request - Arithmetic

2007-12-07 Thread Antony Dovgal
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

Re: [PHP-DEV] Thoughts on Feature Request - Arithmetic

2007-12-07 Thread Robert Cummings
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); // returns

Re: [PHP-DEV] Thoughts on Feature Request - Arithmetic

2007-12-07 Thread Mike
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

Re: [PHP-DEV] Thoughts on Feature Request - Arithmetic

2007-12-07 Thread Daniel Brown
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

Re: [PHP-DEV] Thoughts on Feature Request - Arithmetic

2007-12-07 Thread Hartmut Holzgraefe
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 ...

Re: [PHP-DEV] Thoughts on Feature Request - Arithmetic

2007-12-07 Thread Nathan Rixham
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

Re: [PHP-DEV] Thoughts on Feature Request - Arithmetic

2007-12-07 Thread Richard Lynch
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

Re: [PHP-DEV] Thoughts on Feature Request - Arithmetic

2007-12-07 Thread Nathan Rixham
Daniel and Derick, thanks for the replies.. Daniel first.. ?=3 * 5;? 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