Invalid argument supplied for foreach(), is_array() returns true
<p>I have the following code, and I can't figure out what's wrong with it. I am supplying an array as an argument, and is_array($primes) returns true. Anything I'm missing here?</p>

<pre><code>function generate_primes($max)
{
$i = 4;
$primes = [2, 3];


while($i &lt; $max)
{
    $isPrime = true;

    foreach($primes as $value)
    {
        if($i % $value == 0)
        {
            $isPrime = false;
            break;
        }

    }
    if($isPrime)
        $primes = $i;

    $i++;
}

return $primes;

}
</code></pre>
