0
I searched the web, but I didn’t see how to turn a simple string into a variable, I saw parse_str but it’s not quite what I need. I want the following, I have the string "userName 1", and I would like it to be transformed into "$userName 1".
Suppose I have a Row["field name"] and it goes through a
foreach ($Row as $key => $value),
quero transformar os nomes dos campos em variaveis,
ou seja $."key" = $novovalor
But he won’t take it. I need this because the strings come from a foreach and I don’t know exactly the content, I just know that it is not a content that can give error in the construction of the variable, because they are field names.
Why don’t you do :
$nomeusuario1 = "sua string";
?– MagicHat
There is, but usually you don’t have to do this, in virtually every case it is gambiarra, insecure and the programmer will get hurt with it. And I think it’s been answered before. I need to find.
– Maniero
Because user1 is an example, it does not exist, variables will be created from strings I do not know what are.
– Marcelo
Depending on the answers I will analyze if it is feasible to use the suggestion or go to something else
– Marcelo
Well if you detail a little more the way you receive this data... it gets better
– MagicHat
@Magichat, suppose I have a Row["fieldname"] and it goes through a foreach ($Row as $key => $value), I want to transform the field names into variables, namely $."key" = $novovalor
– Marcelo
Put that code there,,,
– MagicHat
This is a case to use array even associative, as is spoken in the duplicate.
– Maniero