Jump to content

Recommended Posts

Sorry if this has already been answered before but it is a hard problem to find an answer for.  I am making a simple web-based interface that will allow users to add shapes into a DB.  This will involve uploading a shape description, a jpeg of the shape and an equation for the area of the shape.  It doesn't have to be too dynamic so i've kept the equation as a standard format, using x0 -> xn as the variables for the equation.  For example, the equation for the area of a square would be x0 * x0 ( length * length ) as there is only one variable for deriving the area of a square.  A rectangle would be x0 * x1 ( length * height ) etc.  I then have code that reads the equation and counts how many variables, assigns names to these variables etc.  This part is all fine. 

 

When the user selects a rectangle and enters 2 as variable1 and 3 as variable2, the code will retrieve x0*x1 as the rectangle's equation, replace the x0 with 2 and x1 with 3, using str_replace() function.  This all works fine.  So, I'm left with a string stored under a variable with value 2*3  The only problem is that i don't know how to calculate that string.  I don't know how i would return a value of 6.  Will it not always return the value as "2*3" because it is a string?!?

 

God, i hope this isn't a stupidly simple solution  :)

 

Any help would be appreciated

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.