Passing an array with an unknown size to a function
<p>I've been scouring Google for an answer to this problem I'm having and have come up empty so far. </p>

<p>Basically, I'm creating an array of error messages, passing them as an array to a function, looping through the values, formatting and then returning them. For some reason the values do not get passed and I get an "Invalid argument supplied for foreach()" error.</p>

<pre><code>//Create the error array
$error = 0;
$errorArray = array();
if(empty($_POST['amount']))
{
    $error = 1;
    array_push($errorArray,"Amount is required");
}

//Error Function
function makeErrors($err)
{
    $output = 'ul'; 
    foreach($err as $v)
    {
        $output .= '&lt;li&gt;'.$v.'&lt;/li&gt;';
    }
    $output .= '&lt;/ul&gt;';
    return $output;
}

//Show the result
if($error == 1)
{
    $theErrors = makeErrors($errorArray);
    echo $theErrors;
}
</code></pre>

<p>If I just do a plain old print_r on $errorArray I get the expected value, so there's something lost when passing the array to the function. Any suggestions would be much appreciated.</p>
