1
Well I’m with a question where php itself has to create the variable name, I’ve used this feature several times. The problem I am now trying to use this in an array, as follows:
// Cria o nome da variável
$tabela = "tabela1";
// Cria o array
$$tabela[1] = array(
"valor" => $valor
);
Well the code had to create a variable with the name $tabela1
and put the array on it, however it is returning me this error:
Notice: Uninitialized string offset: 3 in teste.php on line 3
Does anyone know what it can be?
is this a multi-dimensional array? I believe what’s wrong is $$table[] = array..., it should be $$table = array...
– Bruno Rigolon
I actually use the
[]
to link the data. I edited the question.– Hugo Borges
Do you want to
$tabela
be an array is that? and at position 1 what value do you want it to have?– Sergio
I don’t want to create a variable with the name
tabela1
and then place an array on it.– Hugo Borges
Why not just use
$tabela1
https://ideone.com/VIQsRv ?– Sergio
So I have a
for
where I have to create some arrays, and it is easier for the code itself to create the names.– Hugo Borges