You have to declare the variable as "global" inside the fonction, that is :
<?PHP
function AlterArray()
{
global $myarray;
// do what I want with the array here
}
$myarray = array (1,2,3,4);
AlterArray();
foreach ($myarray as $num)
{
print $num;
}
?>
or if you have to pass the variable as a parameter (so you can't use the 'global ' directive) :
<?PHP
function AlterArray($var)
{
$GLOBALS[$var]; // Reference your var at a global level
// do what I want with the array here
}
$myarray = array (1,2,3,4);
AlterArray($myarray);
foreach ($myarray as $num)
{
print $num;
}
?>