Return table values in php
<p>I have this code:</p>

<pre><code>public function getYears()
{

     for($yearNum = 1; $yearNum &lt;= 12; $yearNum++){
         $year[]=$this-&gt;year;
        echo $year[$yearNum]=$yearNum;
    }
    return $yearNum;
}
</code></pre>

<p>I have this error:
PHP Warning – yii\base\ErrorException</p>

<p>Invalid argument supplied for foreach()</p>

<p>How can i return this 12 numbers?</p>