I finally got round to updating my PHP install to 7.4 from 7.2 (Planning on going right to current but doing in steps) and a curious error appeared when I was running an existing script:
Message: Trying to access array offset on value of type null
The line that this appears on is simply to populate an array from a simple mysql result set.
for($i = 0; $resultArray[$i] = mysqli_fetch_row($result)[0]; $i++) ;
The script still continues fine but I just don't like any errors. I'm scratching my head why this has errored and searched for a few hours to no avail. Why is this erroring and is there a way to do the same thing with no error?
for($i = 0; $resultArray[$i] = mysqli_fetch_row($result)[0] ?? null; $i++);. This will work, because when mysql_fetch_row() has no more data, it will return null and is also the break condition.