I want to add a new element to an array using a function. This is my code:
$test = [];
$test[] = getTest('test_key');
function getTest($key){
return [$key => 'test_value'];
}
This is the result. A multidimensional array.
Array
(
[0] => Array
(
[test_key] => test_value
)
)
But it's going one level to deep for me :) This is the desired result:
Array
(
[test_key] => test_value
)
What part am I doing wrong? :)