$multiplier=2;
$var=$multiplier." times 3 is ".($multiplier*3);
echo $var.
The code above produces “2 times 3 is 6”.
Let’s make the variable short like the below
$var="multiplier3";
$var=str_replace('multiplier',$multiplier,substr($var,0,-1))*substr($var,-1);
echo $var;
The code above produces “6”.
Now let’s make the variable long like the below.
$var1="Okay, multiplier3 is the answer";
$var2="Yes, multiplier4 is correct";
$var3="Good, multiplier2, nice";
How can I produce or change the variable like the below
“Okay, 6 is the answer” for var1.
“Yes, 8 is correct” for var2
“Good, 4, nice” for var3