Is there a way to turn the addition, subtraction, multiplication and division characters into a string into the actual addition, subtraction, multiplication and division characters, as well as the numbers inside the string, to the actual numbers? Thus, instead of characters acting as part of a string, they will act the same as outside the string, and the same for numbers. Is there a function for this?
$ string = "1 + 1-1 * 1/1";
The required result:
$result = 1+1-1*1/1 = 1;
source
share