I am checking all my code in readiness for upgrading to PHP 8.1.
The following lines of code work fine in PHP7.4 but throws the above error on the line starting with "$pcount" in PHP 8.1
foreach ($products as $product) {
$pcount[$product['HospitalProductID']] += 1;
}
The $product array looks like this:
(
[HospitalProductID] => 260
[HospitalProtocolID] => 82
)
Any idea why PHP 8.1 does not like this code?
source https://stackoverflow.com/questions/70628519/php-8-1-throws-error-uncaught-typeerror-cannot-access-offset-of-type-string-on
Comments
Post a Comment