0

I had some code that has stopped working. I suspect the web server hotel php version has been changed as perfectly good working code no longer works. This is the code. It read in the number of each category from "$catcho" the user chose and created an array of them all. So if the user chose category 1, 3 and 4 the array "$whiskers" would have the values 1, 3 and 4 in it.

while (list ($key, $val) = @each ($catcho)) { 
        $whiskers[] = "$val"; // This builds a list of chosen cats 
}

I have simplified the code because in the final version I don't actually read in all values as they are dependent upon other choices.

What other php code can I put in there instead of mine?

Thanks for any help you are able to give me.

Garry Jones
  • 45
  • 2
  • 8

1 Answers1

2

as 'each' is now removed from php 8+

you can rewrite the construct as

foreach ($catcho as $val){
    $whiskers[] = $val;
}
Clint
  • 973
  • 7
  • 18