Peter.Cort
TF's First Dry Ice User!
- Messages
- 5,018
- Location
- Boston, MA
Hi guys, I'm working on a project and I need to output either a multiplication table, addition table, or division table based on whatever the user puts into a form. I have my function all written out to display the table, and as it stands right now I have an IF statement to figure out which kind of operator they want to use and then have that run to display the table, but I have 3 different functions, and the only change is how I have the calculation. The change is ($x * $y) to ($x + $y) or ($x/$y). Seems unnecessary to have to copy 34 lines of code just to change 1 line.
What I'd like to do is set it up as a function where I can do an IF statement to figure out the operator they want and then put the operator in as a function paramater and run the function that way, so the function would look like ($x ($operator) $y) and the operator would be passed through the function paramaters.
Thoughts?
What I'd like to do is set it up as a function where I can do an IF statement to figure out the operator they want and then put the operator in as a function paramater and run the function that way, so the function would look like ($x ($operator) $y) and the operator would be passed through the function paramaters.
Thoughts?