If I am working with an associate array like such:
Array ( [Username] => user
[Email] => email
)
and I want to add an element to the end, I would think to do:
array_push($array, array('Password' => 'pass'));
However, this leaves me with:
Array ( [Username] => user
[Email] => email
Array ( [Password] => pass )
)
How can this be avoided so I end up with:
Array ( [Username] => user
[Email] => email
[Password] => pass
)
Much appreciated!
$array += array('Password' => 'test');
but be warned it won't override Password if already set. Also, I wouldn't personally do it. Just seemed like an addtional FYI. – Exhaustive