I am developing a dynamic graphing application with php, and the GD Library. It is dynamic in the sense that a user inputs an equation into a text box, and the equation is sent to a .php page where the equation is evaluated and then a graph is produced. I have everything I need to a point. Once the form is submitted, the equation is sent as a string and not as a mathematical equation. So, for example, the user inputs x+2, I have a loop that will go back and replace any x's with a variable x, and the variable x is set and changed, to 10 different numbers, 0 to 10, so that I can get a y-coordinate. But I can never get the $x+2 to evaluate. my expected result would be:
0,2
1,3
and so on.
But instead, I get:
0, 0+2
1, 1+2
Any ideas?