My PHP is quite basic when it comes to functions. I am trying to add a key and value pair to an already existing array via a function. 'Oranges' should also appear in the printed array. Can anyone explain what I am doing wrong?
function add_fruit($ar) {
$ar[] = 'oranges';
}
$fruits = [
'0' => 'apples',
'1' => 'pears',
'2' => 'bananas',
];
add_fruit($fruits);
print_r($fruits);