Fatal error: Cannot use string offset as an array Not making any sense at all <p>I have the fatal error coming up in the error log but it is not affecting the application at all for some reason. This is the code that is running and it makes no sense why it generating the PHP error.</p> <pre><code>for ($i = 1; $i &lt;= $tournament['num_score_fields']; $i++) { $scoresArrayTemp = array( 'score', 'dist', 'dateShot', 'tens', 'nines' ); foreach($scoresArrayTemp AS $val){ if(empty($scores[$i][$val])){ $scores[$i][$val] = ''; } } } </code></pre> <p>The error is generated by this line</p> <pre><code>$scores[$i][$val] = ''; </code></pre> <p>Any help would be greatly appreciated thanks!</p> <p>Based on answer 1 I changed code to this:</p> <pre><code>for ($i = 1; $i &lt;= $tournament['num_score_fields']; $i++) { $scoresArrayTemp = array( 'score'=&gt;'', 'dist'=&gt;'', 'dateShot'=&gt;'', 'tens'=&gt;'', 'nines'=&gt;'' ); if(!is_array($scores[$i])){ $scores[$i] = $scoresArrayTemp; } echo $scores[$i]['score']; } </code></pre> <p>Still gets the error on the last line when echoing out the variable</p>