I've just upgraded to PHP 7.2 and I'm getting PHP Fatal error: Uncaught Error: Cannot use string offset as an array for the line $myarray[$ex][0] = $oldarray[$z]['ID'];
in this old code...
$ex=0;
$z=0;
while($oldarray[$z]['ID']){
if(0==$duplicatename or !$duplicatename){
$ex++;
$myarray[$ex][0] = $oldarray[$z]['ID'];
/*...*/
}
$z++;
}
I've read that the more recent versions of PHP have backward incompatible changes so I changed the offending line to $myarray[$ex]['ID'] = $oldarray[$z]['ID'];
but I'm getting the same error.
The site this code is from is old so I was really expecting more problems than just this one piece of code. Can anyone tell me what I'm doing wrong here please.
Here is a var_dump of $oldarray
, I've edited it slightly to change the content...
array(4) { [0]=> array(11) { ["ID"]=> int(59480) ["boxid"]=> int(11158) ["galleryurl"]=> string(75) "http://..." ["gallerytitle"]=> string(63) "Gallery title goes here" ["gallerytype"]=> string(5) "photo" ["gallerydate"]=> int(1542544634) ["galleryactive"]=> string(1) "y" ["usersubmitted"]=> string(1) "n" ["userip"]=> NULL ["galleryhot"]=> string(1) "n" ["gallidentify"]=> int(372239531175) } 1=> array(11) { ["ID"]=> int(59324) ["boxid"]=> int(11158) ["galleryurl"]=> string(79) "http://..." ["gallerytitle"]=> string(45) "Gallery title goes here" ["gallerytype"]=> string(5) "photo" ["gallerydate"]=> int(1538477012) ["galleryactive"]=> string(1) "y" ["usersubmitted"]=> string(1) "n" ["userip"]=> NULL ["galleryhot"]=> string(1) "n" ["gallidentify"]=> int(428341079414) } }