I am trying to move some PHP scripts from a PC running PHP version 7 to a PC running PHP version 8.
There is problem with following each() query:
do {
$Tabelle->SetLine(array_values($Line));
foreach($Line as $Spalte => $Kapitel) {
list($Name, $URL) = each($URLs[$Spalte]);
if ($URL == "") $Line[$Spalte] = $Name;
else $Line[$Spalte] = '<a href="'.$URL.'">'.$Name.'</a>';
}
} while (reset($Line) != "" || next($Line) != "" || next($Line) != "");
I have customized this as follows:
do {
$Tabelle->SetLine(array_values($Line));
foreach($Line as $Spalte => $Kapitel) {
foreach($URLs[$Spalte] as $Name => $URL)
if ($URL == "") $Line[$Spalte] = $Name;
else $Line[$Spalte] = '<a href="'.$URL.'">'.$Name.'</a>';
}
} while (reset($Line) != "" || next($Line) != "" || next($Line) != "");
It runs on error in an infinite loop!
Then I adjusted it as follows:
$Tabelle->SetLine(array_values($Line));
foreach($Line as $Spalte => $Kapitel) {
foreach($URLs[$Spalte] as $Name => $URL) {
if ($URL == "") $Line[$Spalte] = $Name;
else $Line[$Spalte] = '<a href="'.$URL.'">'.$Name.'</a>';
$Tabelle->SetLine(array_values($Line));
}
}
It works though:
On the old machine, several rows were displayed in 3 columns each.
Now also 3 columns, but 3 times as many rows as usual, and that is
first the values in the first column vary, the 2. and. 3. column remains the same
then the 1st and 3rd columns remain the same and the second varies
then the 1st and 2nd column stays the same and the third varies
2
Answers
I found this solution and it works. Using myEach() instead of each()
I don’t know if your code was working before. but here is PHP8 compatible version of your code: