Add elements in Associative Array - PHP

0

In a typed array, simply count the number of elements in the array and pass this value as an index. But in a one-dimensional associative array, how do I add new elements?

My array is:

$array ['chave1'] = $valor1;
$array ['chave2'] = $valor2;

I know the array_push function but it can not assign a new key to an element, and in the array I need, each element will have a new key.

    
asked by anonymous 20.07.2017 / 09:02

0 answers