The one and probably not so good way of achieving your goal would using global variables.
You could achieve that by adding global $myArr;
to the beginning of your function.
However note that using global variables is in most cases a bad idea and probably avoidable.
The much better way would be passing your array as an argument to your function:
function someFuntion($arr){
$myVal = //some processing here to determine value of $myVal
$arr[] = $myVal;
return $arr;
}
$myArr = someFunction($myArr);