2
I have a variable that has the value of rice, soon after receiving the value of rice, she gets the value ugliness. How do I call the past value of the function? Follow example below:
$arroz = "arroz";
echo $arroz; = arroz
$arroz = "feijao";
echo $arroz; = feijao
echo $arroz-valor-passado = "arroz";
As I know PHP you can’t do that. Only if you keep the value passed in another variable or one array of past values.
– Jorge B.
I didn’t understand that line
echo $arroz-valor-passado = "arroz";
. In addition, the use of a array might be the best choice like @Jorgeb said.– Papa Charlie
@Papacharlie when she does echo puts the expected result forward with the
= resultado
– Jorge B.
@Jorgeb., I understood, could have used
//
, but what I didn’t understand was$arroz-valor-passado
. It is a new nonexistent variable?– Papa Charlie
@That’s Papacharlie. That’s how she wanted it to be...
– Jorge B.
@Jorgeb, I didn’t understand if it was a new var or a new var $rice (subtraction) past value - got confused. Could do something using
extract
, depending on the use of var. It would be better to know the application.– Papa Charlie