The below code does not work as intended.
$fruits = array('apple', 'orange', 'banana', 'cherry');
array_walk($fruits, function($a) {
$a= ucfirst($a);
});
var_dump($fruits);
Why does this work when we pass the reference to an individual entry in the $fruits array.
array_walk(
$fruits,
function(&$a) {
$a = ucfirst($a);
}
);
Note: I know array_map and foreach would work, but why does array_walk() not work?.