$equation = '3 kere 8'; $answer = eval('return ' . (str_replace('kere', '*', $equation)) . ';'); echo $answer;