I have strings that contain simple math problems 1+10, 2+2, 5-3... I'm wanting to be able to match these math problems and replace them with the solution.
So that: Jimmy turns 5+5 on Friday. is changed to: Jimmy turns 10 on Friday.
I dont need multiplication or division at this point so i assume its relatively simple however im not classically trained in PHP. I assume i will need a REGEX to match the problem, but im pretty much lost from there.
1+10 becomes 11
2+2 becomes 4
Just "eval" the replacement - but take care, it's eval (Demo):