Php 菲律宾比索7“;不能将字符串偏移量用作数组;

Php 菲律宾比索7“;不能将字符串偏移量用作数组;,php,Php,我们最近升级到PHP7.4,遇到以下代码块的潜在致命错误警报: $total = 0; $balance = 0; if (is_array($company['history']) && ($histCount = count($company['history']))) { for ($i = $histCount - 1; $i >= 0; $i--) { $total += $company

我们最近升级到PHP7.4,遇到以下代码块的潜在致命错误警报:

$total              = 0;
$balance            = 0;
if (is_array($company['history']) && ($histCount = count($company['history']))) {
    for ($i = $histCount - 1; $i >= 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
    }
}
$company
中的每个
历史记录
元素(除其他外)
金额总计
到期
余额
总计
已初始化,最后两个元素被初始化为
0

EA标记指示的两行,表示“可能引发PHP致命错误(不能将字符串偏移量用作数组)。”

感谢所有能帮助我理解这里出了什么问题的人

附加信息 有人问定义
$company
的代码来自哪里

foreach ($this->orderList as $order) {
    if ($order['amt_paid'] !== $order['real_amt_paid'] && !empty($order['real_amt_paid'])) {
        $order['amt_paid'] = $order['real_amt_paid'];
    }
    $row       = [];
    foreach ($this->customerHistoryColumns as $col) {
        $order[$col[0]] = ($order[$col[0]] === null ? "" : str_replace("&", "&", $order[$col[0]]));
        switch ($col[0]) {
            ...
            case "due":
                $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'];
公司本身在其他地方有定义;这只是检索
历史
元素


FWIW,该代码多年来一直工作完美;正是对Php7的升级引发了这个问题。

这里还发生了其他一些事情。代码看起来不错。定义
$company
的代码是如何和在哪里的?
$company['history'][“$i”]['total']
可能?或者只是删除$i周围的空格?您是否尝试过打印$compay?这应该是因为$company数据有一些意想不到的格式(你们都知道潜在的含义,对吧?)@gihan——是的;数据中没有什么不寻常的地方。这段代码已经稳定了很多年,现在在php7下仍然可以正常运行。