I am having a problem of Undefined variable when I try to use an array inside a function. An example is the code below. How can I be able to access the array $prev inside the function hello()? I've tried searching but I don't really know how to use $GLOBALS[$varname] when the variable is an array. Thanks for any help!
<?php
$prev = [0,1,2];
function hello(){
echo $prev[1];
}
hello();
hello();
hello();
?>
global $prev;to make that var available.