Is there a way for PHP to take a string like "1+2" and find the answer? Something like eval($expression);
It would need to be able to some more complicated math, but not too complicated. (23)/4 would be about as complicated as it got.
Try eval('echo 2+2;');
Well wouldn't the variable:
$numbers = 1+2;
already hold the answer? If you did:
echo $numbers;
, wouldn't it return 3?
i think he means if you had a user input a string like 2+4 or 4/2 or something.