Cannot use string offset as an array (What does it mean?)
<p>The code below is more or less a chunk of my code. The <code>$servername</code> and <code>$monthlyincome</code> variables are not actually static as shown here but I changed them so I could add less code here.</p>

<p>If I run this code... </p>

<pre><code>$servername="Server1";

$months = array('January','February','March','April','May','June','July','August','September','October','November','December');


for ($i=0;$i&lt;=24;$i++) {
    $new_time = mktime(0,0,0,date("m")+$i,1,date("Y"));
    $months_array[date("Y",$new_time)][date("m",$new_time)] = "x";
}

$overallincome = 0;

foreach ($months_array AS $year=&gt;$month) {
    foreach ($month AS $mon=&gt;$x) {
        $monthlyincome = 3;
        $overallincome += $monthlyincome;

        $$servername[$months[$mon-1]." ".$year]['monthlyincome']=$monthlyincome;
        $$servername[$months[$mon-1]." ".$year]['overallincome']=$overallincome;

    }
}
</code></pre>

<p>I get this error...</p>

<p>Cannot use string offset as an array in  on line 123</p>

<p>Line 123 is this line... <code>$$servername[$months[$mon-1]." ".$year]['monthlyincome']=$monthlyincome;</code></p>

<p>I can't figure out what I am doing wrong. I have checked other posts on SO with the same error but nothing made sense to me.</p>
