Search found 3 matches
- Sat Aug 06, 2005 3:20 am
- Forum: PHP - Code
- Topic: [Solved]Calculating expression in string
- Replies: 4
- Views: 389
- Sat Aug 06, 2005 3:16 am
- Forum: PHP - Code
- Topic: [Solved]Calculating expression in string
- Replies: 4
- Views: 389
don't put it in quotes It's not my decision. :) I'm getting the string from mySQL. Keep in mind the order of operations will be in effect. Mulitply and divide first, then subtraction and add, then lastly, left to right so if you want ($price/$duration)*fix or $price/($duration*fix) make sure you sp...
- Fri Aug 05, 2005 6:43 pm
- Forum: PHP - Code
- Topic: [Solved]Calculating expression in string
- Replies: 4
- Views: 389
[Solved]Calculating expression in string
Hi.
I have a string:
$cost = '$price/$duration*$fix';
and I need to calculate the cost.
If I use eval() function, it just replaces variables with numbers,
but it does nothing with operators '/' and '*'.
Is there any other way to do this, except parsing it "manualy"?
Thanks.
I have a string:
$cost = '$price/$duration*$fix';
and I need to calculate the cost.
If I use eval() function, it just replaces variables with numbers,
but it does nothing with operators '/' and '*'.
Is there any other way to do this, except parsing it "manualy"?
Thanks.