-2
In a typed array just count the number of array elements and pass this value as index. But and in a one-dimensional associative array, as I add new elements?
My array is:
$array ['chave1'] = $valor1;
$array ['chave2'] = $valor2;
I know the array_push function but it cannot assign a new key to an element and in the array I need, each element will have a new key.
Wow....
$array['chave3'] = $valor3; .... $array['chaveN'] = $valorN;
– MarceloBoni
It would be the same as
$array = array("chave1" => $valor1,"chave2" => $valor2,"chave3" => $valor3, ... , "chaveN" => $valorN)
– MarceloBoni
https://repl.it/JaQA/1
– MarceloBoni
Marceloboni has already answered you there.
– user13603
Each element must be inserted separately (at different times. Without specifying the order of the elements, one element ends up rewriting the other.
– Guilherme
There’s no sense of it, either you better specific your doubt and your problem, or else that you said has no sense at all
– MarceloBoni