Does anybody know how I can do the following in PHP.
I have a STRING that gets created dynamically. (e.g. $string="2+3+4" or $string="1+5+12" etc....)
I want to do the following:
$result=$string/3
and get a numerical result in $result.
So for example if $string="1+2+3" then $result would be 2. That is 6/2.
Eval was the first thing that came to mind. But it does not seem to work like with other languages.
Also if I have a string like $string="1,2,3"
and I want to use max($string) to get 3 as a result, eval does not seem to work.
Any thoughts? Please let me know.