I'm new at php/programming and would like to know why this doesn't work the way I think It should.
I have an array and I'd like to modify one of its values with a function.
I've been reading and following some tutorials and think it has to do with the variable scope? Or maybe this is just not the way to approach something like this and should use other methods?
<?php
$someArray = array("value1"=> 0, "value2" => 0);
function test ($a) {
if ( 5 > 4 ) {
$a["value1"] += 1;
echo $a["value1"] . "<br/>";
}
}
test($someArray);
echo $someArray["value1"];
?>
What I don't get is why it works when I echo inside the function to get the new value of "value1", but outside it doesn't work. I'd really appreciate any help/guidance and sorry if this is just too dumb or wrong.