title: Php 7 "cannot use string offset as an array"
body: <p>We've recently upgraded to Php 7.4 and are encountering a potential fatal error alert for the following code block:</p>
  <pre><code>$total              = 0;
  $balance            = 0;
  if (is_array($company['history']) &amp;&amp; ($histCount = count($company['history']))) {
      for ($i = $histCount - 1; $i &gt;= 0; $i--) {
          $total   += $company['history'][$i]['amt_total'];
          $balance += $company['history'][$i]['due'];
          $company['history'][ $i ]['balance'] = $balance; // EA flags as potential fatal error
          $company['history'][ $i ]['total']   = $total;   // EA flags as potential fatal error
      }
  }
  </code></pre>
  <p>Each <code>history</code> element in the <code>$company</code> has (among others) <code>amt_total</code>, <code>due</code>, <code>balance</code>, and <code>total</code> initialized, with the last two being initialized to <code>0</code>.</p>
  <p>EA flags the two lines indicated, saying &quot;Could provoke a PHP Fatal error (cannot use string offset as an array).&quot;</p>
  <p>Grateful to anyone who can help me understand what's wrong here.</p>
  <p>ADDITIONAL INFO
  Someone asked where the code for defining <code>$company</code> comes from...</p>
  <pre><code>foreach ($this-&gt;orderList as $order) {
      if ($order['amt_paid'] !== $order['real_amt_paid'] &amp;&amp; !empty($order['real_amt_paid'])) {
          $order['amt_paid'] = $order['real_amt_paid'];
      }
      $row       = [];
      foreach ($this-&gt;customerHistoryColumns as $col) {
          $order[$col[0]] = ($order[$col[0]] === null ? &quot;&quot; : str_replace(&quot;&amp;amp;&quot;, &quot;&amp;&quot;, $order[$col[0]]));
          switch ($col[0]) {
              ...
              case &quot;due&quot;:
                  $row['due'] = $order['amt_total'] - $order['amt_paid'];
                  break;
              ...
              default:
                  $row[$col[0]] = $order[$col[0]];
                  break;
          }
      }
      $row['balance'] = 0;
      $row['total'] = 0;
      $arr['history'][] = $row;
  }
  return $arr['history'];
  </code></pre>
  <p>The company itself is defined elsewhere; this is simply retrieving the <code>history</code> element.</p>
  <p>FWIW, the code has worked flawlessly for years; it's the upgrade to Php7 that has raised this issue.</p>