hi everyone.

i want to use an array ( already created outside the function ) in a function .

here is the code

page1.php
HTML Code:
<form action="page2.php" method="post">
Marks1 = <input type="text" name="marks1" />
Marks2 = <input type="text" name="marks2" />
<input type="submit">
page2.php
PHP Code:
extract($_POST);

$answer=array("$marks1","$marks2");

function 
numcheck($val,$answer)
{
    if(
is_numeric($val))
    {
        return 
$val;
         }
    else
    {
    
$newanswer=serialize($answer);
    
$encode=urlencode($newanswer);
    
header('location:level1test?num=numerror&encode=$encode');
    }
}

$result=array_filter($answer,"numcheck"); 
i am getting this error :- Missing argument 2 for numcheck()



i tried to use array inside the function also like this


PHP Code:
function numcheck($val,$answer)
{
    if(
is_numeric($val))
    {
        return 
$val;
         }
    else
    {

$answer=array("$marks1","$marks2");

    
$newanswer=serialize($answer);
    
$encode=urlencode($newanswer);
    
header('location:level1test?num=numerror&encode=$encode');
    }

But now the error is undefined varible marks1 and marks2





How to get the $answer array inside the function ??