I have created an associative array
$prijs = array (
"Black & Decker Accuboormachine" => 148.85,
"Bosch Boorhamer" => 103.97,
"Makita Accuschroefmachine" => 199.20,
"Makita Klopboormachine" => 76.00,
"Metabo Klopboor" => 119.00
);
Now I have to add a value to the array and I would like to use a function for this.
function itemToevoegen($array, $key, $value){
$array[$key] = $value;
}
Then I call the function:
itemToevoegen($prijs, "Bosch GBH 18 V-LI", 412.37);
I have tried this without putting the array name in the input parameters but that does not work either.
=================== EDIT ===================== While typing this I thought I had to return the value, but that does not give me the desired result either.
function itemToevoegen($array, $key, $value){
return $array[$key] = $value;
}
Could someone help me with this and tell me what I am missing here?
Thanks in advance.