I have a math function, for example:
string = "3x+6.5y-23z"
I need to extract the function and get x
, y
, z
; give value x = 6
, y = 7
, z = 8
; and solve.
you can do it like this
<?php
$x = 6;
$y = 7;
$z = 8;
echo $string = 3*$x+6.5*$y-23*$z;
?>